微信小程序rpx布局,scroll-view高度计算

由于小程序的屏幕宽度总是 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 >

猜你喜欢

转载自blog.csdn.net/weixin_37928483/article/details/80949459
今日推荐