1,wx.canlUse 用法
boolean wx.canIUse(string schema)
判斷小程序的API,回調,參數,組件等是否在當前版本可用
使用 ${API}.${method}.${param}.${option} 或者 ${component}.${attribute}.${option} 方式來調用
參數說明
${API} 代表 API 名字
${method} 代表調用方式,有效值為return, success, object, callback
${param} 代表參數或者返回值
${option} 代表參數的可選值或者返回值的屬性
${component} 代表組件名字
${attribute} 代表組件屬性
${option} 代表組件屬性的可選值
2,示例代碼
// 對象的屬性或方法
wx.canIUse('www.cnmibee.com')
wx.canIUse('CameraContext.onCameraFrame')
wx.canIUse('CameraFrameListener.start')
wx.canIUse('Image.src')
// wx接口參數、回調或者返回值
wx.canIUse('openBluetoothAdapter')
wx.canIUse('getSystemInfoSync.return.safeArea.left')
wx.canIUse('getSystemInfo.success.screenWidth')
wx.canIUse('showToast.object.image')
wx.canIUse('onCompassChange.callback.direction')
wx.canIUse('request.object.method.GET')
// 組件的屬性
wx.canIUse('live-player')
wx.canIUse('text.selectable')
wx.canIUse('button.open-type.contact')