From 0de621d912dd60a0fe46237edfc3135ebd232fed Mon Sep 17 00:00:00 2001 From: "ester.zhou" Date: Fri, 16 Jun 2023 14:48:36 +0800 Subject: [PATCH] Update docs (18854) Signed-off-by: ester.zhou --- .../reference/apis/Readme-EN.md | 3 +- .../reference/apis/js-apis-animator.md | 2 + .../reference/apis/js-apis-mediaquery.md | 8 +-- .../reference/apis/js-apis-promptAction.md | 2 + .../reference/apis/js-apis-syscap.md | 42 ++++++++++++ .../reference/arkui-ts/ts-container-tabs.md | 10 +-- .../arkui-ts/ts-methods-custom-dialog-box.md | 5 +- en/application-dev/reference/syscap.md | 66 ++++++++++++------- 8 files changed, 103 insertions(+), 35 deletions(-) create mode 100644 en/application-dev/reference/apis/js-apis-syscap.md diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 6cdab4d3f2..98af451204 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -148,7 +148,7 @@ - [Common Events of the Ability Subsystem](common_event/commonEvent-ability.md) - [Common Events of the Bundle Management Subsystem](common_event/commonEvent-bundleManager.md) - [Common Events of the Notification Service](common_event/commonEvent-ans.md) - - [Common Events of the Resource Scheduling Subsystem](common_event/commonEvent-resourceschedule.md) + - [Common Events of the Resource Scheduler Subsystem](common_event/commonEvent-resourceschedule.md) - [Common Events of the Telephony Subsystem](common_event/commonEvent-telephony.md) - [Common Events of the USB Subsystem](common_event/commonEvent-usb.md) - Bundle Management @@ -335,6 +335,7 @@ - [@ohos.web.webview (Webview)](js-apis-webview.md) - [Console](js-apis-logs.md) - [Timer](js-apis-timer.md) + - [SysCap](js-apis-syscap.md) - application - [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md) diff --git a/en/application-dev/reference/apis/js-apis-animator.md b/en/application-dev/reference/apis/js-apis-animator.md index 3aaf9f11af..5eb3e73a20 100644 --- a/en/application-dev/reference/apis/js-apis-animator.md +++ b/en/application-dev/reference/apis/js-apis-animator.md @@ -5,6 +5,8 @@ The **Animator** module provides APIs for applying animation effects, including > **NOTE** > > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md). ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-mediaquery.md b/en/application-dev/reference/apis/js-apis-mediaquery.md index e5e74dc82b..b2b8dfd30e 100644 --- a/en/application-dev/reference/apis/js-apis-mediaquery.md +++ b/en/application-dev/reference/apis/js-apis-mediaquery.md @@ -5,6 +5,8 @@ The **mediaquery** module provides different styles for different media types. > **NOTE** > > The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> +> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md). ## Modules to Import @@ -26,7 +28,7 @@ Sets the media query condition. This API returns the corresponding media query l | Name | Type | Mandatory | Description | | --------- | ------ | ---- | ---------------------------------------- | -| condition | string | Yes | Media query condition. For details, see [Syntax of Media Query Conditions](../../ui/arkts-layout-development-media-query.md#syntax-of-media-query-conditions).| +| condition | string | Yes | Media query condition. For details, see [Syntax](../../ui/arkts-layout-development-media-query.md#syntax).| **Return value** @@ -146,7 +148,7 @@ struct MediaQueryExample { } aboutToAppear() { - let portraitFunc = this.onPortrait.bind(this) // Bind the current JS instance. + let portraitFunc = this.onPortrait.bind(this) // Bind the JS instance. this.listener.on('change', portraitFunc) } @@ -158,5 +160,3 @@ struct MediaQueryExample { } } ``` - - \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-promptAction.md b/en/application-dev/reference/apis/js-apis-promptAction.md index 4250e7503f..aed51460eb 100644 --- a/en/application-dev/reference/apis/js-apis-promptAction.md +++ b/en/application-dev/reference/apis/js-apis-promptAction.md @@ -5,6 +5,8 @@ The **PromptAction** module provides APIs for creating and showing toasts, dialo > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md). ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-syscap.md b/en/application-dev/reference/apis/js-apis-syscap.md new file mode 100644 index 0000000000..05439e8cd6 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-syscap.md @@ -0,0 +1,42 @@ +# 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** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| syscap | string | Yes| Name of the SysCap to check.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Check result. The value **true** means that the SysCap is supported, and **false** means the opposite.| + +**Example** + + ```js +import geolocation from '@ohos.geolocation' + +const isLocationAvailable = canIUse('SystemCapability.Location.Location'); +if (isLocationAvailable) { + geolocation.getCurrentLocation((location) => { + console.log(location.latitude, location.longitue); + }); +} else { + console.log('Location not by this device.'); +} + ``` diff --git a/en/application-dev/reference/arkui-ts/ts-container-tabs.md b/en/application-dev/reference/arkui-ts/ts-container-tabs.md index 0acc1c38aa..d03196caff 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-tabs.md +++ b/en/application-dev/reference/arkui-ts/ts-container-tabs.md @@ -21,7 +21,7 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr | Name | Type | Mandatory| Description | | ----------- | --------------------------------- | ---- | ------------------------------------------------------------ | | barPosition | BarPosition | No | Position of the **\** component.
Default value: **BarPosition.Start** | -| index | number | No | Initial tab index.
Default value: **0**
**NOTE**
A value less than 0 evaluates to the default value.
The value ranges from 0 to the number of **\** subnodes minus 1.
When this parameter is set to different values, the slide animation for tab switching is enabled by default. To disable the animation, set **animationDuration** to **0**.
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| +| index | number | No | Initial tab index.
Default value: **0**
**NOTE**
A value less than 0 evaluates to the default value.
The value ranges from 0 to the number of **\** subnodes minus 1.
When this parameter is set to different values, the slide animation for tab switching is enabled by default. To disable the animation, set **animationDuration** to **0**.
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables. | | controller | [TabsController](#tabscontroller) | No | Tab controller. | ## BarPosition @@ -41,9 +41,9 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | vertical | boolean | Whether to use vertical tabs. The value **true** means to use vertical tabs, and **false** means to use horizontal tabs.
Default value: **false**| | scrollable | boolean | Whether the tabs are scrollable. The value **true** means that the tabs are scrollable, and **false** means the opposite.
Default value: **true**| | barMode | BarMode | Tab bar layout mode. For details, see **BarMode**.
Default value: **BarMode.Fixed**| -| barWidth | number \| Length8+ | Width of the tab bar.
**NOTE**

A value less than 0 or greater than the width of the **\** component evaluates to the default value.| -| barHeight | number \| Length8+ | Height of the tab bar.
**NOTE**
A value less than 0 or greater than the width of the **\** component evaluates to the default value. | -| animationDuration | number | Duration of the slide animation for tab switching. If this parameter is set, the tab switching animation is played when the user switches between tabs by sliding or clicking. If this parameter is not set, the tab switching animation is played only when the user switches between tabs by sliding.
Default value: **300**
**NOTE**
A value less than 0 or in percentage evaluates to the default value.| +| barWidth | number \| Length8+ | Width of the tab bar.
The default value varies.
If the tab bar has the **vertical** attribute set to **false** and does not have a style specified, the default value is the width of the **\** component.
If the tab bar has the **vertical** attribute set to **true** and does not have a style specified, the default value is **56vp**.
If the tab bar has the **vertical** attribute set to **false** and **SubTabbarStyle** specified, the default value is the width of the **\** component.
If the tab bar has the **vertical** attribute set to **true** and **SubTabbarStyle** specified, the default value is **56vp**.
If the tab bar has the **vertical** attribute set to **true** and **BottomTabbarStyle** specified, the default value is **96vp**.
If the tab bar has the **vertical** attribute set to **false** and **BottomTabbarStyle** specified, the default value is the width of the **\** component.
**NOTE**

A value less than 0 or greater than the width of the **\** component evaluates to the default value.| +| barHeight | number \| Length8+ | Height of the tab bar.
The default value varies.
If the tab bar has the **vertical** attribute set to **false** and does not have a style specified, the default value is **56vp**.
If the tab bar has the **vertical** attribute set to **true** and does not have a style specified, the default value is the height of the **\** component.
If the tab bar has the **vertical** attribute set to **false** and **SubTabbarStyle** specified, the default value is **56vp**.
If the tab bar has the **vertical** attribute set to **true** and **SubTabbarStyle** specified, the default value is the height of the **\** component.
If the tab bar has the **vertical** attribute set to **true** and **BottomTabbarStyle** specified, the default value is the height of the **\** component.
If the tab bar has the **vertical** attribute set to **false** and **BottomTabbarStyle** specified, the default value is **56vp**.
**NOTE**
A value less than 0 or greater than the height of the **\** component evaluates to the default value. | +| animationDuration | number | Duration of the slide animation for tab switching. If this parameter is set, the tab switching animation is played when the user switches between tabs by sliding or clicking. If this parameter is not set, the tab switching animation is played only when the user switches between tabs by sliding.
Default value: **300**
**NOTE**
A value less than 0 or in percentage evaluates to the default value. | | divider10+ | [DividerStyle](#dividerstyle10) \| null | Whether the divider is displayed for the **\** and **\** components and the divider style. By default, the divider is not displayed.
**DividerStyle**: divider style.
**null**: The divider is not displayed.| | fadingEdge10+ | boolean | Whether the tab fades out when it exceeds the container width.
Default value: **true** | @@ -91,7 +91,7 @@ Switches to the specified tab. | Name | Type | Mandatory | Description | | ----- | ------ | ---- | ---------------------------------------- | -| value | number | Yes | Index of the tab. The value starts from 0.
**NOTE**

If this parameter is set to a value less than 0 or greater than the maximum number, the event will be invalid.| +| value | number | Yes | Index of the tab. The value starts from 0.
**NOTE**
If this parameter is set to a value less than 0 or greater than the maximum number, the event will be invalid. | ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index 343b5b8536..8605a29ab1 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -112,9 +112,10 @@ struct CustomDialogUser { customStyle: false }) + // Delete the dialogController instance and set it to undefined when the custom component is about to be destroyed. aboutToDisappear() { - delete this.dialogController, - this.dialogController = undefined + delete this.dialogController, // Delete the dialogController instance. + this.dialogController = undefined //Set dialogController to undefined. } onCancel() { diff --git a/en/application-dev/reference/syscap.md b/en/application-dev/reference/syscap.md index 03c2f4c42b..f5db3a40c6 100644 --- a/en/application-dev/reference/syscap.md +++ b/en/application-dev/reference/syscap.md @@ -93,29 +93,49 @@ By default, the associated SysCap set of an application is the union of multiple ### Checking Whether an API Is Available -- Method 1: Use the **canIUse()** API to check whether a SysCap is supported. - - ```ts - if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) { - console.log("This device supports SystemCapability.ArkUI.ArkUI.Full."); - } else { - console.log("This device does not support SystemCapability.ArkUI.ArkUI.Full."); - } - ``` - -- Method 2: Import a module using the **import** API. If the current device does not support the module, the import result is **undefined**. Before using an API, you must make sure the API is available. - - ```ts - import geolocation from '@ohos.geolocation'; - - if (geolocation) { - geolocation.getCurrentLocation((location) => { - console.log(location.latitude, location.longitude); - }); - } else { - console.log('This device does not support location information.'); - } - ``` +You can use either the ArtTS or native API to determine whether an API is available. + +- ArkTS API + + - Method 1: Use the **canIUse()** API to check whether a SysCap is supported. + + ```ts + if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) { + console.log("This device supports SystemCapability.ArkUI.ArkUI.Full."); + } else { + console.log("This device does not support SystemCapability.ArkUI.ArkUI.Full."); + } + ``` + + - Method 2: Import a module using the **import** API. If the current device does not support the module, the import result is **undefined**. Before using an API, you must make sure the API is available. + + ```ts + import geolocation from '@ohos.geolocation'; + + if (geolocation) { + geolocation.getCurrentLocation((location) => { + console.log(location.latitude, location.longitude); + }); + } else { + console.log('This device does not support location information.'); + } + ``` +- Native API + + ```c + #include + #include + #include "syscap_ndk.h" + + char syscap[] = "SystemCapability.ArkUI.ArkUI.Full"; + bool result = canIUse(syscap); + if (result) { + printf("SysCap: %s is supported!\n", syscap); + } else { + printf("SysCap: %s is not supported!\n", syscap); + } + ``` + You can also find out the SysCap to which an API belongs by referring to the API reference document. ### Checking the Differences Between Devices with a Specific SysCap -- GitLab