dlt.navigateToMiniProgram
Introduction
Opens another Mini Program from the current page.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| appId | string | Yes | The appId of the Mini Program to open. | |
| path | string | No | The path to the page to open. If empty, the home page will be opened. The part after "?" in the path will become a query, and you can retrieve query data using dlt.getLaunchOptions in the target Mini Program. | |
| extraData | Object | No | Data to be passed to the target Mini Program. The target Mini Program can retrieve this data using dlt.getLaunchOptions. | |
| success | function | No | Callback function called when the interface is successfully invoked. | |
| fail | function | No | Callback function called when the interface invocation fails. | |
| complete | function | No | Callback function called when the interface invocation is complete (called whether the invocation is successful or not). |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| success | string | true - Success |
object.fail Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| success | string | false - Failure |
Sample Code
// pages/index/index.js
Page({
navigateToMiniProgram() {
dlt.navigateToMiniProgram({
appId: 'xxx',
path: 'pages/index/index?a=1',
success: function () {
console.log('success');
},
});
},
});
In the provided sample code, the navigateToMiniProgram function is called to open another Mini Program with the specified appId and path. The success callback logs a message when the operation is successful. Make sure to replace 'xxx' with the actual appId of the target Mini Program and adjust the path as needed.