onLoad () {
uni.getSystemInfo({
success: (res) => {
// 注意这里获得的高度宽度都是px,需要转换rpx
console.log(res.screenHeight); // 屏幕高度,包含导航栏
console.log(res.screenWidth); // 屏幕宽度
console.log(res.windowHeight); // 可使用窗口高度,不包含导航栏
console.log(res.windowWidth); // 可使用窗口宽度
// 可使用窗口高度,将px转换rpx
this.phoneHeight = (res.windowHeight * (750/res.windowWidth))
console.log(this.phoneHeight)
}
})
}
uniapp 获取屏幕高度
最新推荐文章于 2024-06-20 17:25:53 发布