我们用微信接口获取的宽高并不是rpx,我们需要根据rpx的规则手动封装一下:
wx.getSystemInfo({
success: function (res) {
let clientHeight = res.windowHeight;
let clientWidth = res.windowWidth;
let changeHeight = 750 / clientWidth;
let height = clientHeight * changeHeight;
that.setData({
height: height
});
}})
然后在页面调用 height 即可。