Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the route jump mode of WeChat Mini Programs developed by Android?

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what is the route jump mode of WeChat Mini Programs in the development of Android". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the route jump mode of WeChat Mini Programs in Android development?"

Two forms of route redirection: label forms jump to a new page

Use open-type to choose the same jump mode as above

Js format # wxml file jump # js file tiao1:function () {wx.reLaunch ({url:'/ pages/test/test',})}, Quick Summary # wxml file jump # js file tiao1:function () {wx.reLaunch ({url:'/ pages/test/test',})}, / / can only jump to tabBar pages, not non-tabBar pages And close / / all non-tabBar pages. Url cannot take the parameter wx.switchTab ({url:'/ pages/test/test',}) / / close all pages and open a page within the application. His url can take the parameter / / in the onload lifecycle function of the jump page to receive wx.reLaunch ({url:'/ pages/test1/test1?name=123&age=18',}) / / close the current page and jump to a page within the application, but it is not allowed to jump to / / tabbar page His route can also take parameters wx.redirectTo ({url:'/ pages/test1/test1?name='+this.data.name1+'&age=17',}) / / keep the current page, jump to a page in the application, but can not jump to / / tabbar, you can use wx.navigateBack to return to the original page, / / his url can also take parameters The maximum stack of pages in Mini Program is 10 layers wx.navigateTo ({url:'/ pages/test1/test1?name=333',}) / / delat indicates how many layers of wx.navigateBack ({delta:1}) Mini Program routes jump 1.1 wx.switchTab (Object object)

The tabBar here is the page specified in the navigation bar below

Jump to the tabBar page and close all other non-tabBar pages

Parameters.

Object object

The default value of attribute type is required, indicating that urlstring is the path of the tabBar page that needs to be redirected (the page to be defined in the tabBar field of app.json), and the path cannot be followed by parameters. Successfunction No API calls successful callback function failfunction No API calls failed callback function completefunction No API calls the finished callback function (both successful and failed calls will be executed)

Sample code

{"tabBar": {"list": [{"pagePath": "index", "text": "Home"}, {"pagePath": "other", "text": "other"]}} wx.switchTab ({url:'/ index'}) 1.2 wx.reLaunch (Object object)

The basic library 1.1.0 is supported, and the lower version needs to be compatible.

Close all pages and open to a page within the application

Parameters.

Object object

The default value of attribute type is required to indicate that urlstring is the intra-application page path that needs to be redirected, and the path can be followed by parameters. Use between parameters and paths? Separate, parameter keys and parameter values are connected by =, and different parameters are separated by &. For example, 'path?key=value&key2=value2'successfunction No API calls successful callback function failfunction No API calls failed callback function completefunction No API calls end callback function (both successful and failed calls will be executed)

Sample code

Wx.reLaunch ({url: 'test?id=1'}) / / test Page ({onLoad (option) {console.log (option.query)}}) 1.3 wx.redirectTo (Object object)

Close the current page and jump to a page within the application. But you are not allowed to jump to the tabbar page.

Parameters.

Object object

The default value of attribute type is required to indicate that urlstring is the path of non-tabBar pages in the application to be redirected, which can be followed by parameters. Use between parameters and paths? Separate, parameter keys and parameter values are connected by =, and different parameters are separated by &. For example, 'path?key=value&key2=value2'successfunction No API calls successful callback function failfunction No API calls failed callback function completefunction No API calls end callback function (both successful and failed calls will be executed)

Sample code

Wx.redirectTo ({url: 'test?id=1'}) 1.4 wx.navigateTo (Object object)

Keep the current page and jump to a page within the application. But you can't jump to the tabbar page. Use wx.navigateBack to return to the original page. There are up to ten layers of page stack in Mini Program.

Parameters.

Object object

The default value of attribute type is required to indicate that urlstring is the path of non-tabBar pages in the application to be redirected, which can be followed by parameters. Use between parameters and paths? Separate, parameter keys and parameter values are connected by =, and different parameters are separated by &. For example, 'path?key=value&key2=value2'successfunction No API calls successful callback function failfunction No API calls failed callback function completefunction No API calls end callback function (both successful and failed calls will be executed)

Sample code

Wx.navigateTo ({url: 'test?id=1'}) / / test.jsPage ({onLoad (option) {console.log (option.query)}}) 1.5 differences between wx.redirectTo and wx.navigateTo

1. When you jump to the next page using wx.navigateTo (when the onHide method is executed), there will be a return button in the header of the next page

two。 If you do not want to have a return button, you can use wx.redirectTo to jump to the page (when this page is closed, the onUnload life cycle will be executed so that the next page will not have a return button, because the previous page has been closed and there is no page to return to)

1.6 wx.navigateBack (Object object)

Close the current page and return to the previous or multi-level page. You can get the current page stack through getCurrentPages () and decide how many layers you need to return.

Parameters.

Object object

The default value of the attribute type is required, indicating that deltanumber is the number of pages returned. If delta is greater than the number of existing pages, return to the home page. Successfunction No API calls successful callback function failfunction No API calls failed callback function completefunction No API calls the finished callback function (both successful and failed calls will be executed)

Sample code

/ / Note: when a navigateTo jump is called, the page that calls this method will be added to the stack, but the redirectTo method will not. See the sample code below / / here is page A wx.navigateTo ({url: 'indexed 1'}) / / here is page B wx.navigateTo ({url:' Clearidoscopic 1'}) / / navigateBack in page C, and page A wx.navigateBack ({delta: 2}) will be returned. Thank you for reading. This is the content of "what is the route jumping method of WeChat Mini Programs developed by Android". After the study of this article I believe that you have a deeper understanding of what is the way to jump the route of WeChat Mini Programs in the development of Android, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report