方法一: 把弹窗事件写在layer.ready里面
layer.ready(function() { var index = layer.load(2); layer.open({ type: 1, title: false, closeBtn: 0, shadeClose: true, area: ['200px', 'auto'], content: '<img class="closeCode" src="' + dataimg + '" width="100%" />', }); layer.close(index); });
方法二: 在成功以后修改样式
layer.open({ type: 1, title: false, closeBtn: 0, shadeClose: true, area: ['200px', 'auto'], content: '<img class="closeCode" src="' + dataimg + '" width="100%" />', 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: '<img class="closeCode" src="' + dataimg + '" width="100%" />', });

浙公网安备 33010602011771号