UNPKG

miniapp-web-jsapi

Version:

JSAPI/View adapter for miniprogram running on the web

43 lines (42 loc) 1.47 kB
export interface ICallJsApiSuccessResult { [key: string]: any; } export interface ICallJsApiParams { [key: string]: any; /** * 调用成功的回调函数 */ success?(res: ICallJsApiSuccessResult): void; /** * 调用失败的回调函数 */ fail?(res: any): void; /** * 调用结束的回调函数(调用成功、失败都会执行) */ complete?(res: any): void; } export declare function call<Params extends ICallJsApiParams>(apiName: string, params?: Params): any; export declare type JsApiExtensionFunc<T extends ICallJsApiParams, R extends JsApiExtensionFuncResult> = (params?: T | any) => R | void | undefined | null | any; export interface JsApiExtensionFuncResult { [key: string]: any; } interface JsApiExtensionMap { [key: string]: JsApiExtensionFunc<any, any>; } export declare const jsApiExtensions: JsApiExtensionMap; /** * 注册 JSAPI 扩展 * * @param apiName JSAPI 名称 * @param func JSAPI 执行方法 * @param attachToMy 是否挂载到全局的 my 对象上 */ export declare function registerJsApiExtension<T extends ICallJsApiParams, R extends JsApiExtensionFuncResult>(apiName: string, func: JsApiExtensionFunc<T, R>, attachToMy?: boolean): void; /** * 创建不支持的 JSAPI 实现 * @param apiName JSAPI 名称 * @param message 其他提示消息 */ export declare function createUnsupportedJsApi(apiName?: string, message?: string): () => void; export {};