WeChat applet reports error: {"errMsg":"redirectTo:fail can not redirectTo a tabbar page"} and summary of route redirection

WeChat applet reported an error: {"errMsg":"redirectTo:fail can not redirectTo a tabbar page"}

Description of Requirement

Originally, I needed to do a jump event, that is, click the "Submit Assignment" button to complete the submit operation and jump to the original page. I used wx.redirectTo to redirect, but I got an error. The problem is here wx.redirectTo.

Error message

报错:{“errMsg”:“redirectTo:fail can not redirectTo a tabbar page”}
Insert picture description here

Error code

    wx.redirectTo({
    
    
      url: '/pages/study/study',
    })

problem analysis

The study page I jumped to belongs to tabar.
Insert picture description here
The pages belonging to tabbar can only be jumped through wx.switchTab.

problem solved

    // 提交完跳回巩固页面
    wx.switchTab({
    
    
      url: '/pages/study/study',
    })

Because I want to jump to the page that belongs to the tabbar, changing to switchTab can solve the problem~~

Comparison of several jump methods

  1. wx.redirectTo: Close the current page , and then jump to the specified non-TabBar page. Not limited by the number of page layers.
  2. wx.navigateTo: Do ​​not close the current page, but jump to the specified non-TabBar page. Note that the page path limit is five levels . A back button will be displayed in the upper left corner, you can directly return to the previous page.
  3. wx.switchTab: You can only jump to the page belonging to tabBar.

Guess you like

Origin blog.csdn.net/qq_43263320/article/details/113706379