错误信息:
尝试过的方法:
- 在组件生命周期 onShow 里调用
- 使用 try catch 进行兼容, 代码如下:
const getHeaderHeight = (statusBarHeight, isAndroid) => {
let rect = null;
try {
rect = wx.getMenuButtonBoundingClientRect ? wx.getMenuButtonBoundingClientRect() : null;
if (!rect) throw new Error('getMenuButtonBoundingClientRect error');
let gap = rect.top - statusBarHeight;
const navbarHeight = 2 * gap + rect.height;
const wrapHeight = navHeight + statusBarHeight;
return [wrapHeight, navHeight];
} catch(e) {
const navHeight = isAndroid ? 48 : 44;
const wrapHeight = navHeight + statusBarHeight;
return [wrapHeight, navHeight];
}
}
结果:
后台仍然在报错
请问大家有什么好的解决方案吗
客户端版本太低了,这个问题在新的客户端版本有修复,麻烦升级下客户端版本试下