代码片段:https://developers.weixin.qq.com/s/kkM6Htm37Phm
//获取父层高度
var query = wx.createSelectorQuery();
query.select('.details_content').boundingClientRect()
query.exec(function (res) {
var detailH=res[0].height;
that.setData({
detailHeight: detailH+'px',
})
//console.log(res);
})
//获取图片高度
imgH:function(e){
var winWid = wx.getSystemInfoSync().windowWidth;
var imgh = e.detail.height;
var imgw = e.detail.width;
var imgH = winWid * imgh / imgw + 'px';
this.setData({
imgHeight:imgH
})
},
写个代码片段吧。
https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html
https://developers.weixin.qq.com/s/aKOm7tmr78h3