my.navigateToMiniProgram (Object)
This API is supported in mPaaS 10.1.60 and later versions.
This API is used to jump to other Mini programs.
Code sample
my.navigateToMiniProgram({
appId: 'xxxx',
path: 'page/index/index',
extraData:{
"data1":"test"
},
success: (res) => {
console.log(JSON.stringify(res))
},
fail: (res) => {
console.log(JSON.stringify(res))
}
});
Object parameters
Name | Type | Required | Description |
---|---|---|---|
appId | String | Yes | The appId of the target Mini program to jump to. |
path | String | No | The path of the page to open. Open the home page if it is null. |
extraData | Object | No | The data that needs to be passed to the target Mini program. The target Mini program can get this data in App.onLaunch() and App.onShow() . |
success | Function | No | The callback function of calling succeeded. |
fail | Function | No | The callback function of calling failed. |
complete | Function | No | The callback function of calling ended (Execute regardless of the success or failure of the call). |
FAQ
Q: How does the target mini program obtain the data passed by the extraData parameter of
my.navigateToMiniProgram
? Can I add multiple parameters to extraData? What symbol is used as a separator among multiple custom parameters?
A: The above questions are explained as follows- The target mini program can obtain extraData data through
App.onLaunch()
andApp.onShow()
. - Multiple parameters can be added to extraData, and all custom parameters are passed to the target mini program through extraData.-Use
&
to separate multiple custom parameters.
- The target mini program can obtain extraData data through
Q: How can the mini program jump to the “Add favorite for bonus” page?
A: You can refer to the following code.my.navigateToMiniProgram({
appId: '2018122562686742', // The appid of the "Add favorite for bonus" mini program, it is a fixed value, do not modify it
path: 'pages/index/index?originAppId=2017082508366123&newUserTemplate=20190130000000119123', // Link address and parameter
success: (res) => {
// Jumping succeeded
my.alert({ content: 'success' });
},
fail: (error) => {
// Jumping failed
my.alert({ content: 'fail' });
}
});
my.navigateBackMiniProgram (Object)
This API is supported in mPaaS 10.1.60 and later versions.
This API is used to go back to the previous Mini program. The calling successes only when another Mini program jumps to the current program.
Object parameters
Name | Type | Required | Description |
---|---|---|---|
extraData | Object | No | The data that needs to be passed to the target Mini program. The target Mini program can get this data in App.onLaunch() and App.onShow() . |
success | Function | No | The callback function of calling succeeded. |
fail | Function | No | The callback function of calling failed. |
complete | Function | No | The callback function of calling ended (Execute regardless of the success or failure of the call). |
Code sample
my.navigateBackMiniProgram({
extraData:{
"data1":"test"
},
success: (res) => {
console.log(JSON.stringify(res))
},
fail: (res) => {
console.log(JSON.stringify(res))
}
});