uniMP小程序
初始化 sdk 全局环境
示例源码如下,请查看 pre > code 标签中的内容
interface IInitConfig {
debug?: boolean
}
function init(ability: UIAbility, stage: window.WindowStage, config?: IInitConfig)
获取uni小程序应用资源部署路径
示例源码如下,请查看 pre > code 标签中的内容
function getUniMPRunPath(appID: string): string
判断应用资源是否已经部署
示例源码如下,请查看 pre > code 标签中的内容
function isExistsUniMP(appId: string): boolean
将wgt应用资源包部署到运行路径中
示例源码如下,请查看 pre > code 标签中的内容
type ReleaseWgtToRunPathCallback = (code: 1 | -1, error?: Error) => void
function releaseWgtToRunPath(appID: string, wgtPath: string, callback: ReleaseWgtToRunPathCallback)
获取已经部署的小程序应用资源版本信息
示例源码如下,请查看 pre > code 标签中的内容
interface IAppVersionInfo {
name: string
code: string
}
function getAppVersionInfo(appId: string): IAppVersionInfo | null
启动小程序应用并获得IUniMP实例
示例源码如下,请查看 pre > code 标签中的内容
interface ICapsuleStyle {
backgroundColor?: string
textColor?: string
highlightColor?: string
borderColor?: string
}
interface ICapsuleMenuActionSheetItem {
id: string
title: string
}
interface IOpenUniMPConfig {
showCapsuleButton?: boolean
capsuleMenuActionSheetItems?: ICapsuleMenuActionSheetItem[]
capsuleButtonStyle?: ICapsuleStyle
redirectPath?: string
extraData?: Object // 传递给小程序的额外数据,小程序中onLaunch,uni.getLaunchOptionsSync可以获取
}
export interface IUniMP {
hide(): void
show(): void
close(): void
sendUniMPEvent: (event: string, data: ESObject) => void
on(event: 'uniMPEvent', callback: (event: string, data: ESObject, notify: (...args: ESObject[]) => void) => void): void
on(event: 'menuItemClick', callback: (id: string) => void): void
on(event: 'close' | 'show' | 'hide', callback: () => void): void
off(name: string, callback: Function): void
}
function openUniMP(appID: string, config?: IOpenUniMPConfig): IUniMP
IUniMP实例下的API
隐藏当前小程序应用
示例源码如下,请查看 pre > code 标签中的内容
hide(): void
显示当前小程序应用
示例源码如下,请查看 pre > code 标签中的内容
show(): void
关闭当前小程序应用
示例源码如下,请查看 pre > code 标签中的内容
close(): void
向小程序发送事件
示例源码如下,请查看 pre > code 标签中的内容
sendUniMPEvent: (event: string, data: ESObject) => void
监听小程序发送过来的事件
示例源码如下,请查看 pre > code 标签中的内容
on(event: 'uniMPEvent', callback: (event: string, data: ESObject, notify: (...args: ESObject[]) => void) => void): void
监听右上角菜单的点击事件
示例源码如下,请查看 pre > code 标签中的内容
on(event: 'menuItemClick', callback: (id: string) => void): void
监听小程序隐藏、显示、关闭事件
示例源码如下,请查看 pre > code 标签中的内容
on(event: 'close' | 'show' | 'hide', callback: () => void): void
移除对应的监听事件
示例源码如下,请查看 pre > code 标签中的内容
off(name: string, callback: Function): void