ty.navigateToMiniProgram
打开另一个小程序
需引入
BaseKit,且在>=2.5.0版本才可使用
参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| appId | string | 否 | 要打开的小程序 ID | |
| path | string | 否 | 打开的页面路径,如果为空则打开首页,path 中 ? 后面的部分会成为 query,在小程序的 App.onLaunch、App.onShow 和 Page.onLoad 的回调函数 | |
| position | string | 否 | 打开小程序的转场方式,分为 right bottom,指代水平和竖直方向 | |
| extraData | object | 否 | 传递给目标小程序的数据,目标小程序可在 App.onLaunch,App.onShow 中获取到这份数据 | |
| envVersion | 'release'、 'trial' | 否 | 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版 | |
| shortLink | string | 否 | 小程序链接,当传递该参数后,可以不传 appId 和 path | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 |
函数定义示例
/**
* 打开另一个小程序
*/
export function navigateToMiniProgram(params?: {
/** 要打开的小程序 ID */
appId?: string;
/** 打开的页面路径,如果为空则打开首页,path 中 ? 后面的部分会成为 query,在小程序的 `App.onLaunch`、`App.onShow` 和 `Page.onLoad` 的回调函数 */
path?: string;
/** 打开小程序的转场方式,分为right|bottom,指代水平和竖直方向 */
position?: string;
/** 传递给目标小程序的数据,目标小程序可在 `App.onLaunch`,`App.onShow` 中获取到这份数据 */
extraData?: Record<string, any>;
/** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版 */
envVersion?: string;
/** 小程序链接,当传递该参数后,可以不传 appId 和 path */
shortLink?: string;
complete?: () => void;
success?: (params: null) => void;
fail?: (params: {
errorMsg: string;
errorCode: string | number;
innerError: {
errorCode: string | number;
errorMsg: string;
};
}) => void;
}): void;
ty.navigateBackMiniProgram
返回到上一个小程序。只有在当前小程序是被其他小程序打开时可以调用成功
需引入
MiniKit,且在>=2.0.0版本才可使用
参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| extraData | object | 否 | 需要返回给上一个小程序的数据,上一个小程序可在 App.onShow 中获取到这份数据 | |
| complete | function | 否 | 接口调用完成的回调函数(成功或失败都会执行) | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 |
函数定义示例
/**
* 返回到上一个小程序。只有在当前小程序是被其他小程序打开时可以调用成功
*/
export function navigateBackMiniProgram(params?: {
/** 需要返回给上一个小程序的数据,上一个小程序可在 App.onShow 中获取到这份数据 */
extraData?: Record<string, any>;
complete?: () => void;
success?: (params: null) => void;
fail?: (params: {
errorMsg: string;
errorCode: string | number;
innerError: {
errorCode: string | number;
errorMsg: string;
};
}) => void;
}): void;
ty.exitMiniProgram
退出当前小程序
需引入
MiniKit,且在>=2.0.0版本才可使用
参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 |
函数定义示例
/**
* 退出当前小程序
*/
export function exitMiniProgram(params?: {
complete?: () => void;
success?: (params: null) => void;
fail?: (params: {
errorMsg: string;
errorCode: string | number;
innerError: {
errorCode: string | number;
errorMsg: string;
};
}) => void;
}): void;
ty.openInnerH5
打开内置 H5 容器
需引入
BizKit,且在>=3.0.0版本才可使用
参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| url | string | 是 | url H5 链接地址 | |
| title | string | 否 | title H5 标题 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 |
👉 立即开发。

6121

被折叠的 条评论
为什么被折叠?



