.wxml
<navBar title='商品详情' back="{{true}}" home="{{true}}" bindback="handlerGobackClick" bindhome="handlerGohomeClick"></navBar>
.js
// 头部回退按钮
handlerGobackClick: function () {
wx.navigateBack({
delta: 1, // 返回上一级页面。
success: function () {
console.log('成功!')
}
})
},
// 头部首页按钮
handlerGohomeClick: function () {
wx.switchTab({
url: '/pages/index/index'
});
},
.json
{
"usingComponents": {
"navBar": "/components/navbar/index"
}
}
///这是app.json
"window": {
"navigationBarBackgroundColor": "#FFFFFF",
"enablePullDownRefresh": false,
"backgroundColor": "#FFFFFF",
"backgroundTextStyle": "dark",
"navigationStyle": "custom",
"navigationBarTextStyle": "black"
},
需要的文件
.wxml
<navBar title='商品详情' back="{{true}}" home="{{true}}" bindback="handlerGobackClick" bindhome="handlerGohomeClick"></navBar>
.js
// 头部回退按钮
handlerGobackClick: function () {
wx.navigateBack({
delta: 1, // 返回上一级页面。
success: function () {
console.log('成功!')
}
})
},
// 头部首页按钮
handlerGohomeClick: function () {
wx.switchTab({
url: '/pages/index/index'
});
},
.json
{
"usingComponents": {
"navBar": "/components/navbar/index"
}
}