tencent cloud

Tencent Cloud Super App as a Service

DokumentasiTencent Cloud Super App as a Service

Navigation

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-08-25 18:17:54

exitMiniProgram

This API is called using wx.exitMiniProgram(Object object).
Feature description:Exits the current mini program. This API can only be successfully called as a result of a user tap action.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).

navigateToMiniProgram

This API is called using wx.navigateToMiniProgram(Object object).
Feature description:Opens another mini program.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
appId
string
-
True
The appId of the mini program to open.
path
string
-
False
The page path to open. If empty, the home page is opened. The string after the ? in the path will become a query, and the query data can be obtained in the mini program’s callback functions App.onLaunch, App.onShow and Page.onLoad, or in wx.getLaunchOptionsSync.
extraData
object
-
False
Data to pass to the target mini program. It can be obtained in App.onLaunch and App.onShow .
envVersion
string
release
False
The version of the mini program to open. This parameter is valid only when the current mini program is in development version or Preview. If the current mini program is the released version, the mini program that is opened must be the released version. Valid values:
develop: The development version
trial: The preview
release: The released version
urlContent
string
-
False
The URL content of the mini program to open. Accepts links such as scan results from wx.scanCode. When both appId and urlContent are provided, urlContent takes priority.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).

Usage restrictions

User trigger required

If the user does not tap anywhere on the mini program page, the developer will not be able to call this API to automatically navigate to another mini program.

User confirmation required

Before navigating to another mini program, a pop-up window will appear asking for user confirmation, and the navigation will proceed after the user confirms that. If the user taps Cancel, it will trigger a callback with fail cancel.

The appId to be jumped to must be in the navigateToMiniProgramAppIdList configuration list (only applicable to mini games)

When submitting a new version of mini game code, developers must include a list of mini programs/mini games that the mini game may navigate to
in the code configuration if using the navigation feature. The list can be updated with each new version but cannot be dynamically modified. For more information about the configuring method, see Global Configuration. The appId must be in the configuration list, otherwise the fail callback will be triggered with fail appId "${appId}" is not in navigateToMiniProgramAppIdList.
Example:
wx.navigateToMiniProgram({
appId: '',
path: 'page/index/index?id=123',
extraData: {
foo: 'bar'
},
envVersion: 'develop',
urlContent: '',
success(res) {
// Navigation to mini program successful
}
});

navigateBackMiniProgram

This API is called using wx.navigateBackMiniProgram(Object object).
Note:
This API is supported in mini programs but not in mini games.
Feature description:Returns to the previous mini program. This API can be called successfully only when the current mini program is opened by another mini program.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
extraData
Object
{}
False
Data to return to the previous mini program. The previous mini program can access this data in App.onShow.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).
Example:
wx.navigateBackMiniProgram({
extraData: {
foo: 'bar'
},
success(res) {
// Returned to previous mini program successfully
}
})

openEmbeddedMiniProgram

This API is called using wx.openEmbeddedMiniProgram(Object object).
Feature description:Opens an embedded (half-screen) mini program.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
appId
string
-
True
The appId of the mini program to open.
path
string
-
False
The page path to open. If empty, the home page is opened. The string after the ? in the path will become a query, and the query data can be obtained in the mini program's callback functions.
extraData
object
-
False
Data to be passed to the target mini program. The target mini program can access this data through App.onLaunch or App.onShow.
envVersion
string
release
False
The version of the mini program to open. This parameter is effective only when the current mini program is a development or trial version. If the current mini program is a release version, the opened mini program will also be a release version.
Valid values:
develop: The development version
trial: The preview
release: The released version
urlContent
string
-
False
The URL content of the mini program to open. Accepts links such as scan results from wx.scanCode. When both appId and urlContent are provided, urlContent takes priority.
noRelaunchIfPathUnchanged
boolean
false
False
To open the target mini-program directly at the page where it was last suspended in the background (without restarting), the following conditions must be met:
1. The target mini-program's lifecycle has not been destroyed.
2. The `path` and `query` parameters of the current launch are identical to those of the previous launch.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function for API calls (called on both success and failure).
Example:
wx.openEmbeddedMiniProgram({
appId: '',
path: 'page/index/index?id=123',
extraData: {
foo: 'bar'
},
envVersion: 'release',
success(res) {
// Opened successfully
}
})

onEmbeddedMiniProgramHeightChange

This API is called using wx.onEmbeddedMiniProgramHeightChange(function listener).
Feature description:Listens for changes in the visible height of the embedded mini program.
Parameter and description:function listener, the listener function for the embedded mini program's visible height change event.
The parameter of the listener callback is Object res:
Property
Type
Description
height
number
Visible height.
initialHeight
number
Initial height of the embedded mini program.
Example:
const listener = function (res) {
console.log(res.height)
console.log(res.initialHeight)
}
wx.onEmbeddedMiniProgramHeightChange(listener)

offEmbeddedMiniProgramHeightChange

This API is called using wx.offEmbeddedMiniProgramHeightChange(function listener).
Feature description:Removes the listener for the embedded mini program's visible height change event.
Parameter and description:function listener, the listener function that was passed to onEmbeddedMiniProgramHeightChange. If omitted, all listeners are removed.
Example:
const listener = function (res) {
console.log(res)
}
wx.onEmbeddedMiniProgramHeightChange(listener)
wx.offEmbeddedMiniProgramHeightChange(listener) // Must pass the same function reference that was used when subscribing

restartMiniProgram

This API is called using wx.restartMiniProgram(Object object).
Feature description:Restarts the current mini program.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
path
string
-
False
The page path to open after restart. If omitted, the entry page configured in app.json is opened.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function for API calls (called on both success and failure).
Example:
wx.restartMiniProgram({
path: 'pages/index/index',
success(res) {
// Restarted successfully
}
})


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan