返回上一层的navigateBack路由要是与配置的tabBar栏目路由相同的话,返回会失效
,需换用switchTab
//app.json里面设置的tabBar
"tabBar": {
"list": [
{
"text": "返利",
"pagePath": "pages/index/main",
"iconPath": "static/images/menu_home.png",
"selectedIconPath": "static/images/menu_home_active.png"
},
{
"text": "平台",
"pagePath": "pages/hello/main",
"iconPath": "static/images/menu_platform.png",
"selectedIconPath": "static/images/menu_platform_active.png"
}
]
},
<!-- template -->
<a @click="navigateBack" class="home">后退</a>
methods: {
navigateBack(){
wx.navigateBack({
delta: 1,
success: () => {
console.log('success')
},
fail: () => {
console.log('fail')
}
})
},
}
另外,mpvue里面,用标签属性做路由跳转的话,open-type
属性值要注意:
1.open-type="switchTab" 跳转tabBar路由
2.open-type="navigate" 跳转非tabBar路由(默认值)
<a href="/pages/index/main" open-type="switchTab" class="home">去往首页-way1</a>
<a href="/pages/counter/main" open-type="navigate" class="home">去往counter</a>
<navigator open-type="navigateBack" delta="1">返回非tabBar</navigator>
<navigator url="/pages/index/main" open-type="switchTab" delta="1">跳转tabBar</navigator>