插件调用 API 的限制

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

  • 插件的请求域名列表与小程序相互独立;
  • 一些 API 不允许插件调用。
    注意,虽然一些 API 无法调用,但可以用组件来实现相应的功能。典型的例子是 wx.navigateTo

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

API 最低版本
wx.addPhoneContact 1.9.6
wx.arrayBufferToBase64 1.9.6
wx.base64ToArrayBuffer 1.9.6
wx.canvasGetImageData 1.9.6
wx.canvasPutImageData 1.9.6
wx.canvasToTempFilePath 1.9.6
wx.chooseImage 1.9.6
wx.chooseLocation 1.9.6
wx.chooseVideo 1.9.6
wx.closeBLEConnection 1.9.6
wx.closeBluetoothAdapter 1.9.6
wx.connectSocket 1.9.6
wx.createAnimation 1.9.6
wx.createAudioContext 1.9.6
wx.createBLEConnection 1.9.6
wx.createCameraContext 1.9.6
wx.createCanvasContext 1.9.6
wx.createInnerAudioContext 1.9.6
wx.createIntersectionObserver 1.9.6
wx.createLivePlayerContext 1.9.6
wx.createLivePusherContext 1.9.6
wx.createMapContext 1.9.6
wx.createSelectorQuery 1.9.6
wx.createVideoContext 1.9.6
wx.downloadFile 1.9.6
wx.getBLEDeviceCharacteristics 1.9.6
wx.getBLEDeviceServices 1.9.6
wx.getBackgroundAudioManager 1.9.6
wx.getBackgroundAudioPlayerState 1.9.6
wx.getBeacons 1.9.6
wx.getBluetoothAdapterState 1.9.6
wx.getBluetoothDevices 1.9.6
wx.getClipboardData 1.9.6
wx.getConnectedBluetoothDevices 1.9.6
wx.getHCEState 2.1.0
wx.getImageInfo 1.9.6
wx.getLocation 1.9.6
wx.getNetworkType 1.9.6
wx.getRecorderManager 1.9.94
wx.getScreenBrightness 1.9.6
wx.getStorage 1.9.6
wx.getStorageSync 1.9.6
wx.getSystemInfo 1.9.6
wx.getSystemInfoSync 1.9.6
wx.hideLoading 1.9.6
wx.hideToast 1.9.6
wx.makePhoneCall 1.9.6
wx.makeVoIPCall 1.9.6
wx.navigateBack 2.1.0
wx.notifyBLECharacteristicValueChange 1.9.6
wx.notifyBLECharacteristicValueChanged 1.9.6
wx.onAccelerometerChange 1.9.6
wx.onBLECharacteristicValueChange 1.9.6
wx.onBLEConnectionStateChange 1.9.6
wx.onBLEConnectionStateChanged 1.9.6
wx.onBackgroundAudioPause 1.9.6
wx.onBackgroundAudioPlay 1.9.6
wx.onBackgroundAudioStop 1.9.6
wx.onBeaconServiceChange 1.9.6
wx.onBeaconUpdate 1.9.6
wx.onBluetoothAdapterStateChange 1.9.6
wx.onBluetoothDeviceFound 1.9.6
wx.onCompassChange 1.9.6
wx.onHCEMessage 2.1.0
wx.onNetworkStatusChange 1.9.6
wx.onUserCaptureScreen 1.9.6
wx.openBluetoothAdapter 1.9.6
wx.openLocation 1.9.6
wx.pauseBackgroundAudio 1.9.6
wx.pauseVoice 1.9.6
wx.playBackgroundAudio 1.9.6
wx.playVoice 1.9.6
wx.previewImage 1.9.6
wx.readBLECharacteristicValue 1.9.6
wx.removeStorage 1.9.6
wx.removeStorageSync 1.9.6
wx.reportAnalytics 1.9.6
wx.request 1.9.6
wx.saveImageToPhotosAlbum 1.9.6
wx.saveVideoToPhotosAlbum 1.9.6
wx.scanCode 1.9.6
wx.seekBackgroundAudio 1.9.6
wx.sendHCEMessage 2.1.0
wx.setClipboardData 1.9.6
wx.setKeepScreenOn 1.9.6
wx.setScreenBrightness 1.9.6
wx.setStorage 1.9.6
wx.setStorageSync 1.9.6
wx.showActionSheet 1.9.6
wx.showLoading 1.9.6
wx.showModal 1.9.6
wx.showToast 1.9.6
wx.startAccelerometer 1.9.6
wx.startBeaconDiscovery 1.9.6
wx.startBluetoothDevicesDiscovery 1.9.6
wx.startCompass 1.9.6
wx.startHCE 2.1.0
wx.startRecord 1.9.6
wx.stopAccelerometer 1.9.6
wx.stopBackgroundAudio 1.9.6
wx.stopBeaconDiscovery 1.9.6
wx.stopBluetoothDevicesDiscovery 1.9.6
wx.stopCompass 1.9.6
wx.stopHCE 2.1.0
wx.stopRecord 1.9.6
wx.stopVoice 1.9.6
wx.uploadFile 1.9.6
wx.vibrateLong 1.9.6
wx.vibrateShort 1.9.6
wx.writeBLECharacteristicValue 1.9.6

原文:

https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/api-limit.html