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

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

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

posted @ 2021-01-22 09:36  小泽沐优声  阅读(704)  评论(0编辑  收藏  举报