UNIAPP—获取设备系统信息(高度、宽度)【uni.getSystemInfo】
官方文档:https://uniapp.dcloud.net.cn/api/system/info.html
onLoad () {
uni.getSystemInfo({
success: (res) => {
// *****高度宽度的单位都是px
console.log(res.screenHeight); // 屏幕高度,包含导航栏
console.log(res.windowHeight); // 能够使用的窗口高度,不包含导航栏
console.log(res.screenWidth); // 屏幕宽度
console.log(res.windowWidth); // 能够使用的窗口宽度
// 能够使用的窗口高度,将px转换rpx
this.windowHeight = (res.windowHeight * (750/res.windowWidth))
console.log(this.windowHeight)
}
})
}