真机获取状态栏高度失效、延迟,昨天开发发现(2020年1月16日)

发布于 8 年前作者 li467557 次浏览最后编辑 8 年前来自 issues
wx.getSystemInfo({
  success: function (res) {
    that.globalData.statusBarHeight = res.statusBarHeight;
  },
  fail:function(res){
  }
})

有时候进入小程序能获取状态栏高度,页面正常,有时候进入不能获取状态栏高度

  

注:自定义标题栏

2 回复
fang87
fang871 楼6 年前

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

lei24
lei242 楼6 年前

获取不到再次获取一次

  setCustom() {
    let that = this
    wx.getSystemInfo({
      successe => {
        that.globalData.StatusBar = e.statusBarHeight
        let customA = wx.getMenuButtonBoundingClientRect()
        if (!customA.bottom) {
          that.globalData.CustomBar = e.platform == 'android' ? e.statusBarHeight + 50 : e.statusBarHeight + 45
          
        } else {
          let custom = customA
          that.globalData.Custom = custom
          that.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight

        }
        
      }
    })
  },