layer弹窗第一次不居中。然后再点击就居中了。解决办法
方法一: 把弹窗事件写在layer.ready里面
layer.ready(function() { var index = layer.load(2); layer.open({ type: 1, title: false, closeBtn: 0, shadeClose: true, area: ['200px', 'auto'], content: '', }); layer.close(index); });
方法二: 在成功以后修改样式
layer.open({ type: 1, title: false, closeBtn: 0, shadeClose: true, area: ['200px', 'auto'], content: '', success:function(layero,index){ layer.style(index, { top: '50%', transform:'translateY(-50%)' }); } });
方法三: 写个固定的宽高
layer.open({ type: 1, title: false, closeBtn: 0, shadeClose: true, area: ['200px', '200px'], content: '', });
参考---https://blog.csdn.net/qq_33769914/article/details/97009173?spm=1001.2101.3001.6650.10&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-10.highlightwordscore&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-10.highlightwordscore