wx.navigateTo跳转首页无效

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

原创文章 241 获赞 169 访问量 72万+

猜你喜欢

转载自blog.csdn.net/yusirxiaer/article/details/103651901