mpvue中navigateBack失效于tabBar

返回上一層的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 ⊙▽⊙

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容