返回上一層的navigateBack路由要是與配置的tabBar欄目
路由相同的話,返回會失效,需換用switchTab
//app.json里面設(shè)置的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里面,用標簽屬性做路由跳轉(zhuǎn)的話,
open-type屬性值要注意:
1.open-type="switchTab" 跳轉(zhuǎn)tabBar路由
2.open-type="navigate" 跳轉(zhuǎn)非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">跳轉(zhuǎn)tabBar</navigator>
--by Affandi ⊙▽⊙