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”}
Error code
wx.redirectTo({
url: '/pages/study/study',
})
problem analysis
The study page I jumped to belongs to tabar.
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
- wx.redirectTo: Close the current page , and then jump to the specified non-TabBar page. Not limited by the number of page layers.
- 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.
- wx.switchTab: You can only jump to the page belonging to tabBar.