<
image
src=
"/images/1.jpg"
bindload=
"imageLoad"
style=
"width:{{imgwidth}}rpx; height:{{imgheight }}rpx;"></
image
>
imageLoad:
function (e) {
var _this =
this;
var $width = e.detail.width,
//获取图片真实宽度
$height = e.detail.height,
ratio = $width / $height;
//图片的真实宽高比例
var viewWidth =
800,
//设置图片显示宽度,
viewHeight =
800 / ratio;
//计算的高度值
this.setData({
imgwidth: viewWidth,
imgheight: viewHeight
})
}