问题: 首页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来跳转