問題: 首頁A—B,B—C,C—A(回首頁無效)
先來看首頁,首頁是由tabBar中三個頁面組成
再來看下首頁的代碼組成
//只保留核心代碼
"tabBar": {
? ? ...?
? ? "list": [
? ? ? {
? ? ? ? "pagePath": "pages/home/home",
? ? ? ? "text": "小Q規劃",
? ? ?? ?...
? ? ? },
? ? ? {
? ? ? ? "pagePath": "pages/news/news",
? ? ? ? "text": "早知道",
? ? ? ? ...
? ? ? },
? ? ? {
? ? ? ? "pagePath": "pages/mine/mine",
? ? ? ? "text": "我的",
? ? ? ? ...
? ? ? }
? ? ]
? },
現在從首頁跳轉到B頁面,B跳轉到C頁面,但是從C跳轉到首頁時無效,代碼如下:
此段代碼跳回首頁無效!!!
?? ?wx.redirectTo({
?? ? ? url: '../home/home',
?? ?}) ?
解決方法: 使用wx.switchTab()方法跳轉
?? ?wx.switchTab({
?? ? ? ? ?url: '../home/home',
?? ?}) ?
總結 :
首頁被tabBar所包含的頁面必須使用wx.switchTab來跳轉
?