layer.open自适应图片大小主要是先获取到图片的width和height,然后设置到layer.open的area里
function getImg(imgUrl){
var img = new Image();
//图片地址
img.src = imgUrl;
if (img.complete) {
var win_w = img.width;
var win_h = img.height;
openLayer(win_w, win_h, imgUrl);
} else {
img.onload = function () {
var win_w = img.width;
var win_h = img.height;
openLayer(win_w, win_h, imgUrl);
}
}
}
function openLayer(win_w, win_h, imgUrl){
layer.open({
title: false,
area: [win_w, win_h],
skin: 'clear_style',
btn: false,
content: '<img src="' + imgUrl + '">'
})
}