Open Another Mini Program from the Current Page
methodName: navigateToMiniProgram
Additional Parameters:
Property | Type | Required | Default | Description |
---|---|---|---|---|
appId | String | Yes | The appId of the mini program to open. | |
path | String | No | The page path to open in the target mini program. If it's empty, the target mini program's home page will be opened. Any text after ? in the path becomes the query, which can be retrieved using dlt.getLaunchOptions in the target mini program. | |
extraData | String | No | Data to be passed to the target mini program. The target mini program can access this data in App.onLaunch and App.onShow . |
Success Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
success | String | Describes whether the interface call was successful or not. "true" for success, "false" for failure. |
Fail Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
success | String | Describes whether the interface call was successful or not. "true" for success, "false" for failure. |
errMsg | String | Error message. |
Example Usage
const dlt = window['@transsion/byteh5bridge'];
const canCallDlt = dlt && window.dltms && window.dltms.isMiniShellGame();
if (canCallDlt) {
dlt.callApi('navigateToMiniProgram', {
appId: '1xxxx',
path: 'pages/index/index?a=xxx',
extraData: JSON.stringify({ apple: 'red' }),
success: (res) => {
console.log('Success: ', res);
},
fail: (res) => {
console.log('Fail: ', res);
},
complete: (res) => {
console.log('Complete: ', res);
},
});
}