All Products
Search
Document Center

Mobile Platform as a Service:Mini program jumping

Last Updated:Feb 19, 2021

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

  1. my.navigateToMiniProgram({
  2. appId: 'xxxx',
  3. path: 'page/index/index',
  4. extraData:{
  5. "data1":"test"
  6. },
  7. success: (res) => {
  8. console.log(JSON.stringify(res))
  9. },
  10. fail: (res) => {
  11. console.log(JSON.stringify(res))
  12. }
  13. });

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() and App.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.
  • Q: How can the mini program jump to the “Add favorite for bonus” page?
    A: You can refer to the following code.

    1. my.navigateToMiniProgram({
    2. appId: '2018122562686742', // The appid of the "Add favorite for bonus" mini program, it is a fixed value, do not modify it
    3. path: 'pages/index/index?originAppId=2017082508366123&newUserTemplate=20190130000000119123', // Link address and parameter
    4. success: (res) => {
    5. // Jumping succeeded
    6. my.alert({ content: 'success' });
    7. },
    8. fail: (error) => {
    9. // Jumping failed
    10. my.alert({ content: 'fail' });
    11. }
    12. });

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

  1. my.navigateBackMiniProgram({
  2. extraData:{
  3. "data1":"test"
  4. },
  5. success: (res) => {
  6. console.log(JSON.stringify(res))
  7. },
  8. fail: (res) => {
  9. console.log(JSON.stringify(res))
  10. }
  11. });