uni-app uni.getSystemInfo 获取到的 windowHeight 不符合

uni-app uni.getSystemInfo 获取到的 windowHeight 不符合

操作步骤:

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

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

image


更多关于uni-app uni.getSystemInfo 获取到的 windowHeight 不符合的实战教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

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

更多关于uni-app uni.getSystemInfo 获取到的 windowHeight 不符合的实战教程也可以访问 https://www.itying.com/category-93-b0.html


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?

我也遇到了 楼主解决了吗

回到顶部