微信小程序获取导航栏高度

小程序获取右上角胶囊位置信息

// 获取设备信息
uni.getSystemInfo({
success: e => { // { statusBarHeight: 20, ... },单位为 px
// 获取右上角胶囊的位置信息
let info = uni.getMenuButtonBoundingClientRect() // { bottom: 58, height: 32, left: 278, right: 365, top: 26,  87 },单位为 px
let CustomBar = info.bottom + info.top - e.statusBarHeight
console.log('设备信息',CustomBar)
}
})

原文地址:https://www.cnblogs.com/1748sb/p/14311613.html