跳到主要内容

Manycore.ThirdParty.WeChat.MiniProgram.callAPIAsync() function

微信小程序通用接口 参数及可用接口见如下链接的相关接口 1部分 https://developers.weixin.qq.com/miniprogram/dev/component/web-view.html 禁止使用函数类型的入参, 跳转类型的success&fail已被转换成promise

Signature:

function callAPIAsync<Params extends any[] = any[]>(functionName: string, ...params: Params): Promise<any>;

Links: function callAPIAsync<Params extends any[] = any[]>(functionName: string, ...params: Params): Promise<any>;

Parameters

Parameter

Type

Description

functionName

string

函数名称 比如navigateTo

params

Params

入参参考微信小程序文档,其中函数类型的入参不支持

Returns:

Promise<any>

Example 1

跳转至详情页

Manycore.ThirdParty.WeChat.MiniProgram.callAPIAsync('navigateTo', { url: '/pages/detail' }).then(success, fail)

getEnv 与微信文档有所出入,由出参来判断是否是在小程序环境内

Example 2

判断网页是否在小程序内

const isInWebView = (await Manycore.ThirdParty.WeChat.MiniProgram.callAPIAsync('getEnv')).miniprogram

@vm-type AsyncFunctionType