uniapp 计算状态栏和导航栏高度


uni.getSystemInfo({
 success:function(e){
  this.$options.globalData.statusBar = e.statusBarHeight
  // #ifndef MP
  if(e.platform == 'android') {
    this.$options.globalData.customBar = e.statusBarHeight + 50
  }else {
    this.$options.globalData.customBar = e.statusBarHeight + 45
  }
  // #endif

  // #ifdef MP-WEIXIN

  //获取胶囊按钮的布局位置信息,坐标信息以屏幕左上角为原点
  let custom = wx.getMenuButtonBoundingClientRect()   

  //导航栏高度 = 状态栏到胶囊的间距(胶囊距上距离-状态栏高度) * 2 + 胶囊高度 + 状态栏高度。

  this.$options.globalData.customBar = custom.bottom + custom.top - e.statusBarHeight
  // #endif

  // #ifdef MP-ALIPAY
  this.$options.globalData.customBar = e.statusBarHeight + e.titleBarHeight
  // #endif
 }
})


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM