最近在研究小程序,遇到计算高度的问题, 随手记录下来:
height: function() {
var that = this;
wx.getSystemInfo({
success: function(res) {
var clientHeight = res.windowHeight,//获取窗口高度px
clientWidth = res.windowWidth,//获取窗口宽度px
rpx_r = 750 / clientWidth;// px与rpx换算比例(ps:请自行搜索px和rpx换算)
var height = clientHeight * rpx_r; // 窗口的高度rpx
}
});
},
网友评论