Boolean mc.canIUse(String schema)
判断应用的API,回调,参数,组件等是否在当前版本可用。
参数
| 参数 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| schema | String | 是 | 使用 ${API}.${method}.${param}.${option} 或者 ${component}.${attribute}.${option} 方式来调用 |
返回值
| 类型 | 说明 |
|---|---|
| Boolean | 当前版本是否可用 |
参数说明:
${API}代表 API 名字${method}代表调用方式,有效值为return, success, object, callback${param}代表参数或者返回值${option}代表参数的可选值或者返回值的属性${component}代表组件名字${attribute}代表组件属性${option}代表组件属性的可选值
示例代码:
// 对象的属性或方法
mc.canIUse('env.USER_DATA_PATH')
mc.canIUse('console.log')
mc.canIUse('BackgroundAudioManager.play')
// mc接口参数、回调或者返回值
mc.canIUse('openBluetoothAdapter')
mc.canIUse('getSystemInfoSync.return.safeArea.left')
mc.canIUse('getSystemInfo.success.screenWidth')
mc.canIUse('showToast.object.image')
// 组件的属性
mc.canIUse('editor')
mc.canIUse('text.selectable')
mc.canIUse('icon.type.waiting')