title: Taro.canIUse(schema)

sidebar_label: canIUse

Determines whether the APIs, callbacks, parameters, and components of the Mini Program are available in the current version.

Reference

Type

  1. (schema: string) => boolean

Parameters

The API is called using the ${API}.${method}.${param}.${options} or ${component}.${attribute}.${option} method.

Parameters Description

- ${API}: API name - ${method}: Call method. Available values: return, success, object, and callback. - ${param}: Parameter or return value - ${option}: Available values for the parameter - ${component}: Component name - ${attribute}: Component attribute - ${option}: Available values for the component attribute

Sample Code

  1. Taro.canIUse('openBluetoothAdapter')
  2. Taro.canIUse('getSystemInfoSync.return.screenWidth')
  3. Taro.canIUse('getSystemInfo.success.screenWidth')
  4. Taro.canIUse('showToast.object.image')
  5. Taro.canIUse('onCompassChange.callback.direction')
  6. Taro.canIUse('request.object.method.GET')
  7. Taro.canIUse('live-player')
  8. Taro.canIUse('text.selectable')
  9. Taro.canIUse('button.open-type.contact')

API Support

API WeChat Mini-Program H5 React Native
Taro.canIUse ✔️