微信小程序 插件调用API的限制


本文整理自网络,侵删。

插件调用 API 的限制

插件可以调用的 API 与小程序不同,主要有两个区别:

  • 插件的请求域名列表与小程序相互独立;
  • 一些 API 不允许插件调用(这些函数不存在于 wx 对象下)。

有些接口虽然在插件中不能使用,但可以通过插件功能页来达到目的,请参考插件功能页。

目前,允许插件调用的 API 及其对应版本要求如下:

基础

API最低版本备注
wx.arrayBufferToBase64
wx.base64ToArrayBuffer

发起请求

API最低版本备注
wx.request1.9.6

上传、下载

API最低版本备注
wx.downloadFile1.9.6
wx.uploadFile1.9.6

WebSocket

API最低版本备注
wx.connectSocket1.9.6

图片

API最低版本备注
wx.previewImage1.9.6
wx.chooseImage1.9.6
wx.getImageInfo1.9.6
wx.saveImageToPhotosAlbum1.9.6

录音

API最低版本备注
wx.startRecord1.9.6
wx.stopRecord1.9.6

实时音视频

API最低版本备注
wx.createLivePlayerContext1.9.6
wx.createLivePusherContext1.9.6

录音管理

API最低版本备注
wx.getRecorderManager1.9.94

音频播放控制

API最低版本备注
wx.pauseVoice1.9.6
wx.playVoice1.9.6
wx.stopVoice1.9.6

音乐播放控制

API最低版本备注
wx.onBackgroundAudioPlay1.9.6
wx.getBackgroundAudioPlayerState1.9.6
wx.onBackgroundAudioStop1.9.6
wx.stopBackgroundAudio1.9.6
wx.onBackgroundAudioPause1.9.6
wx.seekBackgroundAudio1.9.6
wx.playBackgroundAudio1.9.6
wx.pauseBackgroundAudio1.9.6

背景音频播放管理

API最低版本备注
wx.getBackgroundAudioManager1.9.6

音频组件控制

API最低版本备注
wx.createInnerAudioContext1.9.6
wx.createAudioContext1.9.6

视频

API最低版本备注
wx.chooseVideo1.9.6
wx.saveVideoToPhotosAlbum1.9.6

视频组件控制

API最低版本备注
wx.createVideoContext1.9.6

相机组件控制

API最低版本备注
wx.createCameraContext1.9.6

数据缓存

API最低版本备注
wx.setStorage1.9.6
wx.getStorage1.9.6
wx.removeStorage1.9.6
wx.setStorageSync1.9.6
wx.getStorageSync1.9.6
wx.removeStorageSync1.9.6

获取位置

API最低版本备注
wx.getLocation1.9.6
wx.chooseLocation1.9.6
wx.onLocationChange2.8.0
wx.offLocationChange2.9.1
wx.stopLocationUpdate2.8.0
wx.startLocationUpdate2.8.0

查看位置

API最低版本备注
wx.openLocation1.9.6

地图组件控制

API最低版本备注
wx.createMapContext1.9.6

系统信息

API最低版本备注
wx.getSystemInfoSync1.9.6
wx.getSystemInfo1.9.6

屏幕亮度

API最低版本备注
wx.setKeepScreenOn1.9.6
wx.setScreenBrightness1.9.6
wx.getScreenBrightness1.9.6

用户截屏事件

API最低版本备注
wx.onUserCaptureScreen1.9.6仅限插件页面中调用
wx.offUserCaptureScreen2.9.1仅限插件页面中调用

振动

API最低版本备注
wx.vibrateLong1.9.6
wx.vibrateShort1.9.6

手机联系人

API最低版本备注
wx.addPhoneContact1.9.6

NFC

API最低版本备注
wx.sendHCEMessage2.1.0
wx.stopHCE2.1.0
wx.onHCEMessage2.1.0
wx.offHCEMessage2.9.1
wx.startHCE2.1.0
wx.getHCEState2.1.0

网络状态

API最低版本备注
wx.onNetworkStatusChange1.9.6
wx.offNetworkStatusChange2.9.1
wx.getNetworkType1.9.6

加速度计

API最低版本备注
wx.startAccelerometer1.9.6
wx.stopAccelerometer1.9.6
wx.onAccelerometerChange1.9.6
wx.offAccelerometerChange2.9.1

设备方向

API最低版本备注
wx.startDeviceMotionListening2.9.1
wx.stopDeviceMotionListening2.9.1
wx.offDeviceMotionChange2.9.1
wx.onDeviceMotionChange2.9.1

陀螺仪

API最低版本备注
wx.startGyroscope2.9.1
wx.stopGyroscope2.9.1
wx.offGyroscopeChange2.9.1
wx.onGyroscopeChange2.9.1

罗盘

API最低版本备注
wx.onCompassChange1.9.6
wx.offCompassChange2.9.1
wx.stopCompass1.9.6
wx.startCompass1.9.6

拨打电话

API最低版本备注
wx.makePhoneCall1.9.6

扫码

API最低版本备注
wx.scanCode1.9.6

剪贴板

API最低版本备注
wx.setClipboardData1.9.6
wx.getClipboardData1.9.6

蓝牙

API最低版本备注
wx.writeBLECharacteristicValue1.9.6
wx.startBluetoothDevicesDiscovery1.9.6
wx.getConnectedBluetoothDevices1.9.6
wx.notifyBLECharacteristicValueChange1.9.6
wx.onBluetoothDeviceFound1.9.6
wx.offBluetoothDeviceFound2.9.1
wx.readBLECharacteristicValue1.9.6
wx.openBluetoothAdapter1.9.6
wx.getBLEDeviceCharacteristics1.9.6
wx.stopBluetoothDevicesDiscovery1.9.6
wx.onBLEConnectionStateChange1.9.6
wx.getBluetoothDevices1.9.6
wx.getBluetoothAdapterState1.9.6
wx.onBluetoothAdapterStateChange1.9.6
wx.offBluetoothAdapterStateChange2.9.1
wx.getBLEDeviceServices1.9.6
wx.onBLECharacteristicValueChange1.9.6
wx.offBLECharacteristicValueChange2.9.1
wx.createBLEConnection1.9.6
wx.closeBluetoothAdapter1.9.6
wx.closeBLEConnection1.9.6
wx.notifyBLECharacteristicValueChange1.9.6
wx.onBLEConnectionStateChange1.9.6
wx.offBLEConnectionStateChange2.9.1

iBeacon

API最低版本备注
wx.getBeacons1.9.6
wx.startBeaconDiscovery1.9.6
wx.onBeaconServiceChange1.9.6
wx.offBeaconServiceChange2.9.1
wx.onBeaconUpdate1.9.6
wx.offBeaconUpdate2.9.1
wx.stopBeaconDiscovery1.9.6

Wi-Fi

API最低版本备注
wx.connectWifi2.9.1
wx.getConnectedWifi2.9.1
wx.getWifiList2.9.1
wx.offGetWifiList2.9.1
wx.offWifiConnected2.9.1
wx.onEvaluateWifi2.9.1
wx.onGetWifiList2.9.1
wx.onWifiConnected2.9.1
wx.presetWifiList2.9.1
wx.setWifiList2.9.1
wx.startWifi2.9.1
wx.stopWifi2.9.1

交互反馈

API最低版本备注
wx.hideLoading1.9.6
wx.showActionSheet1.9.6
wx.showLoading1.9.6
wx.hideToast1.9.6
wx.showToast1.9.6
wx.showModal1.9.6

设置导航条

API最低版本备注
wx.showNavigationBarLoading2.1.0仅限插件页面中调用
wx.hideNavigationBarLoading2.1.0仅限插件页面中调用
wx.setNavigationBarColor2.1.0仅限插件页面中调用
wx.setNavigationBarTitle2.1.0仅限插件页面中调用

背景

API最低版本备注
wx.setBackgroundColor2.4.0仅限插件页面中调用
wx.setBackgroundTextStyle2.4.0仅限插件页面中调用

WXML节点信息

API最低版本备注
wx.createSelectorQuery1.9.6

WXML节点布局相交状态

API最低版本备注
wx.createIntersectionObserver1.9.6

导航

API最低版本备注
wx.navigateBack2.1.0仅限插件页面中调用
wx.navigateTo2.2.2仅限插件页面中调用
wx.redirectTo2.2.2仅限插件页面中调用
wx.switchTab2.3.1仅限插件页面中调用
wx.reLaunch2.3.1仅限插件页面中调用

动画

API最低版本备注
wx.createAnimation1.9.6

位置

API最低版本备注
wx.pageScrollTo2.1.0仅限插件页面中调用

绘图

API最低版本备注
wx.createOffscreenCanvas2.7.1
wx.canvasPutImageData1.9.6
wx.canvasToTempFilePath1.9.6
wx.createCanvasContext1.9.6
wx.canvasGetImageData1.9.6

下拉刷新

API最低版本备注
wx.stopPullDownRefresh2.1.0仅限插件页面中调用
wx.startPullDownRefresh2.1.0仅限插件页面中调用

当前帐号信息

API最低版本备注
wx.getAccountInfoSync2.2.2

转发

API最低版本备注
wx.hideShareMenu2.1.0仅限插件页面中调用
wx.getShareInfo2.1.0仅限插件页面中调用
wx.showShareMenu2.1.0仅限插件页面中调用
wx.updateShareMenu2.1.0仅限插件页面中调用

其他

API最低版本备注
wx.getSetting2.6.3
wx.openSetting2.10.3
wx.reportAnalytics1.9.6见下方备注

登录和获取用户信息

这一组接口仅限在用户信息功能页中获得用户授权之后调用。否则将返回 fail 。详见 用户信息功能页 。

API最低版本备注
wx.login2.3.1
wx.getUserInfo2.3.1

提示:

  • wx.reportAnalytics 可以被正常调用,但目前不会进行统计展示。



标签:微信小程序

相关阅读 >>

微信小程序云开发api 替换更新一条记录

微信小程序云开发 第一个云开发小程序

微信小程序 广告-banner 广告

微信小程序api 绘图createcirculargradient(创建圆形渐变)

微信小程序云开发sdk文档 常量

微信小程序api 地图组件控制

微信小程序 msgseccheck

微信小程序api 绘图setstrokestyle(设置线条样式)

微信小程序api 视频解码器-videodecoder实例

微信小程序 运力方使用onmockupdateorder

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...