Essential APIs

navigateBackMiniProgram

Return to the previous Mini Program after being opened by another Mini Program.

Overview

my.navigateBackMiniProgram allows your Mini Program to return to the previous Mini Program. This API is only used when another Mini Program has jumped to your foregrounded Mini Program, enabling you to navigate back and optionally pass data.

This API should only be called when your Mini Program was opened by another Mini Program using my.navigateToMiniProgram. It returns control to the calling Mini Program.

Sample Code

my.navigateBackMiniProgram({
  extraData: {
    "data1": "test"
  },
  success: (res) => {
    console.log(JSON.stringify(res))
  },
  fail: (res) => {
    console.log(JSON.stringify(res))
  }
});

Parameters

PropertyTypeRequiredDescription
extraDataObjectNoThe extra data that needs to be returned to the target Mini Program. The target Mini Program can get it in App.onLaunch() or App.onShow().
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).

Usage Notes

  • This API only works when your Mini Program was opened by another Mini Program
  • Data passed via extraData can be accessed in the previous Mini Program's lifecycle methods
  • The user will be returned to the Mini Program that originally navigated to yours