目录

API Availability Check

has.canIUse

has.canIUse(string schema): boolean

Checks whether a specified API (including call methods, parameters, return values, and return value properties) or component (including attributes) is available in the current version.

Since: 1.0.0

Parameters

Parameter Type Mandatory Description
schema string Yes

Call format. For details about the parameters, see the "Format description" below.

- Call format for an API: ${API}.${method}.${param}.${option}

- Call format for a component: ${component}.${attribute}.${option}

Format description

Name Description
${API} API name.
${method} Call method, which can be return, success, object, and callback.
${param} Parameter or return value.
${option} Parameter value or return value property.
${component} Component name.
${attribute} Component attribute.
${option} Value of the component attribute.

Returns:

A Boolean value, indicating whether the API or component is available.

Example:

// Check whether an API is available.
has.canIUse('getFileInfo');
// Check whether a property of the API is available.
has.canIUse('closeSocket.object.code');
// Check whether a property of the API is available.
has.canIUse('getLocation.success.latitude');
// Check whether a return value of the API is available.
has.canIUse('getSystemInfo.success.screenWidth');
// Check whether a component is available.
has.canIUse('radio');
// Check whether an attribute value of the component is available.
has.canIUse('button.size.default');