uniapp 获取屏幕高度
onLoad () {uni.getSystemInfo({success: (res) => {// 注意这里获得的高度宽度都是px,需要转换rpxconsole.log(res.screenHeight); // 屏幕高度,包含导航栏console.log(res.screenWidth); // 屏幕宽度console.log(res.windowHeight); // 可使用窗口高度
·
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)
}
})
}
更多推荐
已为社区贡献10条内容
所有评论(0)