uniapp-兼容H5和微信小程序, 自定义导航栏
- 动态的样式无法编译到微信小程序。
- 动态传过来的函数无法编译到微信小程序。
UNIAPP自定义导航栏适配问题和微信小程序齐刘海适配问题
代码:
// #ifdef MP-WEIXIN
let systemInfo = uni.getSystemInfoSync()
// 获取头部状态栏> 就是显示电量的那部分。因为有个齐刘海的问题要处理
this.statusBarHeight = systemInfo.statusBarHeight
// 获取微信小程序右上角胶囊按钮的API
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
// 胶囊按钮距离最上方的高度 - 状态条的高度 * 2 + 胶囊按钮的高度 + 状态条的高度
this.statusBarHeight = (menuButtonInfo.top - this.statusBarHeight) + menuButtonInfo.height + systemInfo.statusBarHeight
// #endif
详解图: