How to solve the problem of WeChat Mini Programs preventing being unable to return to the home page
This article mainly explains "how to solve the problem that WeChat Mini Programs can not return to the home page". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn how to solve the problem that WeChat Mini Programs can not return to the home page.
Problem scenario:
After a page of Mini Program is completed, you want to jump to another related page.
For example, after the order is submitted, you want to jump to the order details page. There are two options.
A uses wx.navigateTo to jump to a non-tabBar page
The advantage is that there is a back button, which can return to the home page step by step
The disadvantage is that the user experience is poor, and it is possible to reissue orders.
B use wx.redirectTo to jump to a non-tabBar page
The advantage is that the old page will not be returned
The disadvantage is that it is unable to return to the home page, resulting in an endless loop
Solution.
1. Use the wx.reLaunch feature with parameters to jump to the tabbar page, such as
Wx.reLaunch ({url:'/ pages/me/me?pageId=mypublishhome'})
2. Add judgment to the onLoad of the pages/me/me page to manage the jump, so that the newly opened page
Pages/me/mypublishhome/mypublishhome can return to the tabbar page, and then go to other home pages.
OnLoad: function (options) {that = this; console.log ('options of the current page is', options); the existence of the value of if (options.pageId) {/ / this pageId proves that the opening of the home page comes from the user clicking console.log ('the options of the current page is', options.pageId) Wx.navigateTo ({url:'/ pages/me/' + options.pageId +'/'+ options.pageId,})}} so far, I believe you have a better understanding of "how to solve the problem that WeChat Mini Programs can not return to the home page". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!