
wx.canIUse(String)
判断小程序的API,回调,参数,组件等是否在当前版本可用。
String参数说明:使用${API}.${method}.${param}.${options}或者${component}.${attribute}.${option}方式来调用,例如:
${API}代表 API 名字${method}代表调用方式,有效值为return,success,object,callback${param}代表参数或者返回值${options}代表参数的可选值${component}代表组件名字${attribute}代表组件属性${option}代表组件属性的可选值
例子:
console.log(wx.canIUse('openBluetoothAdapter'));
console.log(wx.canIUse('getSystemInfoSync.return.screenWidth'))
console.log(wx.canIUse('getSystemInfo.success.screenWidth'))
console.log(wx.canIUse('showToast.object.image'))
console.log(wx.canIUse('onCompassChange.callback.direction'))
console.log(wx.canIUse('request.object.method.GET'))
console.log(wx.canIUse('live-player'))
console.log(wx.canIUse('text.selectable'))
console.log(wx.canIUse('button.open-type.contact'))