Small Program jump encounters pitfalls, small program jump encounters
Beginner Skip. The path route you wrote is correct, but it does not respond to any clicks. It may be due to the following reasons: 1. You need to jump to the page in the tabBar, use the exclusive jump Method switchtab2: In the app. js does not configure this page 3: Is the page level more than five layers. You can use the destroy redirect method wx. navigateTo (OBJECT) to retain the current page, jump to a page in the application, and use wx. navigateBack to return to the original page. OBJECT parameter description:
Parameters |
Type |
Required |
Description |
Url |
String |
Yes |
The path of the non-tabBar page in the application to be redirected. The path can contain parameters. Between Parameters and paths? Separated, parameter keys and parameter values are connected with =, and different parameters are separated with &; for example, 'path? Key = value & key2 = value2' |
Success |
Function |
No |
Callback Function for successful API call |
Fail |
Function |
No |
Callback Function for interface call failure |
Complete |
Function |
No |
The callback function after the interface call ends. (The callback function is executed if the call succeeds or fails) |
Sample Code: wx. navigateTo ({url: 'test? Id = 1'}) // test. jsPage ({onLoad: function (option) {console. log (option. query)}) Note: currently, the page path can be at most 10 layers. Wx. redirectTo (OBJECT) closes the current page and jumps to a page in the application. OBJECT parameter description:
Parameters |
Type |
Required |
Description |
Url |
String |
Yes |
The path of the non-tabBar page in the application to be redirected. The path can contain parameters. Between Parameters and paths? Separated, parameter keys and parameter values are connected with =, and different parameters are separated with &; for example, 'path? Key = value & key2 = value2' |
Success |
Function |
No |
Callback Function for successful API call |
Fail |
Function |
No |
Callback Function for interface call failure |
Complete |
Function |
No |
The callback function after the interface call ends. (The callback function is executed if the call succeeds or fails) |
Sample Code: wx. redirectTo ({url: 'test? Id = 1 '}) wx. reLaunch (OBJECT)
Basic Library 1.1.0 is supported, and earlier versions must be compatible
Close all pages and open a page in the application. OBJECT parameter description:
Parameters |
Type |
Required |
Description |
Url |
String |
Yes |
The page path of the application to be redirected. The path can contain parameters. Between Parameters and paths? Separated, parameter keys and parameter values are connected with =, and different parameters are separated with &; for example, 'path? Key = value & key2 = value2 '. If the redirected page path is a tabBar page, no parameter is required. |
Success |
Function |
No |
Callback Function for successful API call |
Fail |
Function |
No |
Callback Function for interface call failure |
Complete |
Function |
No |
The callback function after the interface call ends. (The callback function is executed if the call succeeds or fails) |
Sample Code: wx. reLaunch ({url: 'test? Id = 1'}) // test. jsPage ({onLoad: function (option) {console. log (option. query)}) wx. switchTab (OBJECT) jumps to the tabBar page, and closes all other non-tabBar Page OBJECT parameter descriptions:
Parameters |
Type |
Required |
Description |
Url |
String |
Yes |
The path of the tabBar page to be redirected (the page defined by the tabBar field in app. json is required). The path cannot contain parameters. |
Success |
Function |
No |
Callback Function for successful API call |
Fail |
Function |
No |
Callback Function for interface call failure |
Complete |
Function |
No |
The callback function after the interface call ends. (The callback function is executed if the call succeeds or fails) |
Sample Code: {"tabBar": {"list": [{"pagePath": "index", "text": "Homepage" },{ "pagePath ": "other", "text": "other"}]} wx. switchTab ({url: '/Index'}) wx. navigateBack (OBJECT) closes the current page and returns the previous page or multi-level page. You can use getCurrentPages () to obtain the current page stack and determine the number of layers to be returned. OBJECT parameter description:
Parameters |
Type |
Default Value |
Description |
Delta |
Number |
1 |
Number of returned pages. If delta is greater than the number of existing pages, return to the home page. |
Sample Code: // Note: When navigateTo 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 wx. navigateTo ({url: 'B? Id = 1 '}) // the wx. navigateTo ({url: 'C? Id = 1 '}) // navigateBack on Page C. navigateBack ({delta: 2}) I encountered a tabBar pitfall because I directly log on to the page to jump to the home page (the home page is in the app. in the tabBar bar of json), wx should be used. switchTab