基础库 2.33.0 开始支持,低版本需做兼容处理。
小程序插件:不支持
功能描述
监听 API 类别变化事件
参数
function listener
API 类别变化事件的监听函数
参数
Object res
| 属性 | 类型 | 说明 | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| apiCategory | number | API 类别 | |||||||||||||
|
|||||||||||||||
不同 apiCategory 场景下的 API 限制
X 表示 API 被限制无法使用;不在表格中的 API 不限制。
| default | nativeFunctionalized | browseOnly | embedded | chatTool | |
|---|---|---|---|---|---|
| openSetting | X |
||||
| <button open-type="share"> | X |
X |
X |
X |
|
| <button open-type="feedback"> | X |
||||
| <button open-type="open-setting"> | X |
||||
| navigateToMiniProgram | X |
X |
X |
||
| openEmbeddedMiniProgram | X |
X |
X |
X |
|
| openOfficialAccountArticle | X |
||||
| openChannelsUserProfile | X |
||||
| ad | X |
||||
| ad-custom | X |
||||
| 小程序菜单分享 | X |
示例代码
const func = function (res) {
console.log(res.apiCategory)
}
wx.onApiCategoryChange(func)
// 取消监听
wx.offApiCategoryChange(func)