获取当前用户屏幕可显示尺寸
在wxss中可以在
page{
overflow:hidden;
}
防止页面1/2px的滚动
onLoad: function (options) {
var that = this// 获取系统信息
wx.getSystemInfo({
success: function (res) {
console.log(res);
// 可使用窗口宽度、高度
console.log('height=' + res.windowHeight);
console.log('width=' + res.windowWidth);
// 计算主体部分高度,单位为px
that.setData({
second_height: res.windowHeight
})
}
})
},
本文介绍了在微信小程序中如何获取屏幕可显示尺寸,以实现全屏布局。通过设置`page{overflow:hidden;}`避免1/2px滚动问题,并在`onLoad`函数中获取尺寸信息。
1万+

被折叠的 条评论
为什么被折叠?



