Mini Program jumping

更新时间:
复制 MD 格式

my.navigateToMiniProgram (Object)

Note

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() 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.

    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)

Note

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 Mini 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))
    }
});