openharmony 鸿蒙 js-apis-syscap

2025-06-12 浏览 (1)

SysCap

SystemCapability (SysCap) refers to a standalone feature in the operating system. Different devices support different SysCap sets. Each SysCap corresponds to one or more APIs. You can determine whether an API can be used by checking SysCap support.

NOTE

The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.

canIUse

canIUse(syscap: string): boolean

Checks whether a SysCap is supported.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
syscapstringYesName of the SysCap to check.Null and undefined inputs are not supported.

Return value

TypeDescription
booleanCheck result. The value true means that the SysCap is supported, and false means the opposite.

Example

import { geoLocationManager } from '@kit.LocationKit'
import { BusinessError } from '@kit.BasicServicesKit';

const isLocationAvailable = canIUse('SystemCapability.Location.Location.Core');
if (isLocationAvailable) {
  geoLocationManager.getCurrentLocation((err: BusinessError, location: geoLocationManager.Location) => {
      if (err) {
          console.error('err=' + JSON.stringify(err));
      }
      if (location) {
          console.log('location=' + JSON.stringify(location));
      }
  });
} else {
  console.log('Location not by this device.');
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Common Capabilities

harmony 鸿蒙_j_s_v_m

harmony 鸿蒙JSVM_CallbackStruct

harmony 鸿蒙JSVM_CreateVMOptions

harmony 鸿蒙JSVM_ExtendedErrorInfo

harmony 鸿蒙JSVM_HeapStatistics

harmony 鸿蒙JSVM_InitOptions

harmony 鸿蒙JSVM_PropertyDescriptor

harmony 鸿蒙JSVM_PropertyHandlerConfigurationStruct

harmony 鸿蒙JSVM_ScriptOrigin

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/YoplAN