uniapp 获取屏幕高度

 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)
      }
    })
  }

猜你喜欢

转载自blog.csdn.net/qq_40146789/article/details/124398718