ace_cy
ace_cy
  • 发布:2021-04-01 23:07
  • 更新:2021-09-05 20:48
  • 阅读:1382

【报Bug】uni.getSystemInfo 获取到的windowHeight不符合。

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows 10专业版 19041.867

HBuilderX类型: 正式

HBuilderX版本号: 3.1.7

手机系统: Android

手机系统版本号: Android 11

手机厂商: 小米

手机机型: Redmi K20 Pro Premium Edition

页面类型: nvue

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:
uni.getSystemInfo({  
        success: (res) => {  
          this.contentTop = res.safeArea.top  
          this.screenHeight = res.safeArea.height  
          console.log("res: " + JSON.stringify(res));  
        }  
      })

预期结果:

{"errMsg":"getSystemInfo:ok","brand":"Xiaomi","model":"Redmi K20 Pro Premium Edition","pixelRatio":2.75,"screenWidth":851,"screenHeight":393,"windowWidth":851,"windowHeight":393,"statusBarHeight":35,"language":"zh-CN","system":"11","version":"1.9.9.80770","fontSizeSetting":"","platform":"android","SDKVersion":"","windowTop":0,"windowBottom":0,"safeArea":{"left":0,"right":851,"top":35,"bottom":393,"width":851,"height":358},"safeAreaInsets":{"top":35,"right":0,"bottom":0,"left":0},"deviceId":"81EA8531377655EA08F729A46D2882E6"}

实际结果:

{"errMsg":"getSystemInfo:ok","brand":"Xiaomi","model":"Redmi K20 Pro Premium Edition","pixelRatio":2.75,"screenWidth":851,"screenHeight":393,"windowWidth":851,"windowHeight":393,"statusBarHeight":35,"language":"zh-CN","system":"11","version":"1.9.9.80770","fontSizeSetting":"","platform":"android","SDKVersion":"","windowTop":0,"windowBottom":0,"safeArea":{"left":0,"right":851,"top":35,"bottom":393,"width":851,"height":358},"safeAreaInsets":{"top":35,"right":0,"bottom":0,"left":0},"deviceId":"81EA8531377655EA08F729A46D2882E6"}

bug描述:

  export default {  
    data() {  
      return {  
        contentTop: 0,  
        contentHeight: 0,  
      };  
    },  
    created() {  
      uni.getSystemInfo({  
        success: (res) => {  
          this.contentTop = res.safeArea.top  
          this.screenHeight = res.safeArea.height  
          console.log("res: " + JSON.stringify(res));  
        }  
      })  
    },  
  }

手机底部的白条,没有减去它的高度

2021-04-01 23:07 负责人:无 分享
已邀请:
DCloud_UNI_Anne

DCloud_UNI_Anne

高度相关信息,要放在 onReady 里获取

  • ace_cy (作者)

    res: {"errMsg":"getSystemInfo:ok","brand":"Xiaomi","model":"Redmi K20 Pro Premium Edition","pixelRatio":2.75,"screenWidth":851,"screenHeight":393,"windowWidth":851,"windowHeight":393,"statusBarHeight":35,"language":"zh-CN","system":"11","version":"1.9.9.80770","fontSizeSetting":"","platform":"android","SDKVersion":"","windowTop":0,"windowBottom":0,"safeArea":{"left":0,"right":851,"top":35,"bottom":393,"width":851,"height":358},"safeAreaInsets":{"top":35,"right":0,"bottom":0,"left":0},"deviceId":"81EA8531377655EA08F729A46D2882E6"}


    onReady获取到的也是一模一样的。注意看题目了吗?全面屏的安卓机,底部有一条小白条操作栏,获取到的安全高度,应该减去底部这一栏,或者你们提供一下获取底部操作栏高度的API?

    2021-04-06 21:00

1***@qq.com

1***@qq.com

我也遇到了 楼主解决了吗

该问题目前已经被锁定, 无法添加新回复