计算公式:导航栏高度 = (胶囊top - 状态栏高度) * 2 + 胶囊高度
导航栏模式
"navigationStyle": "custom"
wxml
<view style="height: {{statusBarHeight}}px;line-height: {{statusBarHeight}}px;background-color: #000;"></view>
<view style="height: {{navHeight}}px;line-height: {{navHeight}}px;background-color: red;color: #FFF;text-align: center;">导航栏</view>
js
let _menuInfo = wx.getMenuButtonBoundingClientRect();
let _windowInfo = wx.getWindowInfo()
let _navHeight = (_menuInfo.top - _windowInfo.statusBarHeight) * 2 + _menuInfo.height;
console.log(_navHeight);
this.setData({
statusBarHeight:_windowInfo.statusBarHeight,
navHeight:_navHeight
});