真机获取状态栏高度失效、延迟,昨天开发发现(2020年1月16日)
发布于 6 年前 作者 li46 7374 次浏览 来自 官方Issues
wx.getSystemInfo({
  success: function (res) {
    that.globalData.statusBarHeight = res.statusBarHeight;
  },
  fail:function(res){
  }
})

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

  

注:自定义标题栏

2 回复

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

获取不到再次获取一次

  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

        }
        
      }
    })
  },
回到顶部