如何自定义头部
首先需要在页面的json文件中配置头部信息"navigationStyle": "custom"
然后使用微信的apiwx.getMenuButtonBoundingClientRect()
获取右上角的交胶囊按钮的布局位置信息
根据获取到的信息调整自定义头部的位置
<view class="index-header" style="padding-top: {{pointobj.top}}px; width: {{pointobj.left}}px;">
onLoad() {
// 获取胶囊按钮定位
let obj = wx.getMenuButtonBoundingClientRect()
console.log(obj)
this.setData({
pointobj: obj
})
}