由于小程序的屏幕宽度总是 750rpx
所以我们可以根据宽高比来算出屏幕高度的rpx
wx.getSystemInfo({
success: function (res) {
let clientHeight = res.windowHeight,
clientWidth = res.windowWidth,
rpxR = 750 / clientWidth;
var calc = clientHeight * rpxR;
console.log(calc)
that.setData({
windowHeight: calc
});
}
});
作用就是scroll-view的情况下动态设置高度
<scroll-view style='height:{{windowHeight-80}}rpx;'>
</scroll-view>