diff --git a/en/application-dev/reference/apis/js-apis-system-time.md b/en/application-dev/reference/apis/js-apis-system-time.md index 35e09c4168db955cf6a5d5741a536dcd0711c3b7..b23a5156cca257811966b42775ca542f29f0b3c0 100644 --- a/en/application-dev/reference/apis/js-apis-system-time.md +++ b/en/application-dev/reference/apis/js-apis-system-time.md @@ -1,18 +1,17 @@ -# Setting the System Time +# System Time and Time Zone -This module is used to set and obtain the current system date, time, and time zone. - -> **NOTE**
The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +The **systemTime** module provides system time and time zone features. You can use the APIs of this module to set and obtain the system time and time zone. +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import - -``` +```js import systemTime from '@ohos.systemTime'; ``` - ## systemTime.setTime setTime(time : number, callback : AsyncCallback<void>) : void @@ -25,25 +24,24 @@ Sets the system time. This API uses an asynchronous callback to return the resul **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| time | number | Yes| Timestamp to set, in milliseconds.| -| callback | AsyncCallback<void> | Yes| Callback used to process the received return value.| +| Name | Type | Mandatory| Description | +| -------- | ----------- | ---- | ---------------- | +| time | number | Yes | Timestamp to set, in milliseconds. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js +```js // Set the system time to 2021-01-20 02:36:25. - var time = 1611081385000; - systemTime.setTime(time, (error, data) => { - if (error) { - console.error(`failed to systemTime.setTime because ` + JSON.stringify(error)); - return; - } - console.log(`systemTime.setTime success data : ` + JSON.stringify(data)); - }); - ``` - +let time = 1611081385000; +systemTime.setTime(time, (error) => { + if (error) { + console.error(`Failed to set systemTime. Cause:` + JSON.stringify(error)); + return; + } + console.log('Succeeded in setting systemTime.'); +}); +``` ## systemTime.setTime @@ -57,28 +55,27 @@ Sets the system time. This API uses a promise to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| time | number | Yes| Timestamp to set, in milliseconds.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| time | number | Yes | Timestamp to set, in milliseconds.| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<void> | Promise used to return the result.| +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js +```js // Set the system time to 2021-01-20 02:36:25. -var time = 1611081385000; -systemTime.setTime(time).then((data) => { - console.log(`systemTime.setTime success data : ` + JSON.stringify(data)); +let time = 1611081385000; +systemTime.setTime(time).then(() => { + console.log('Succeeded in setting systemTime.'); }).catch((error) => { - console.error(`failed to systemTime.setTime because ` + JSON.stringify(error)); + console.error(`Failed to set systemTime. Cause:` + JSON.stringify(error)); }); - ``` - +``` ## systemTime.getCurrentTime8+ @@ -90,23 +87,22 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| -| callback | AsyncCallback<number> | Yes| Callback used to return the time.| +| Name | Type | Mandatory| Description | +| -------- | -------------- | ---- | ------------------ | +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds (ns).
- **false**: in milliseconds (ms).| +| callback | AsyncCallback<number> | Yes | Callback used to return the time elapsed since the Unix epoch. | **Example** - ```js - systemTime.getCurrentTime(true, (error, data) => { - if (error) { - console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); - return; - } - console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); - }); - ``` - +```js +systemTime.getCurrentTime(true, (error, data) => { + if (error) { + console.error(`Failed to get systemTime. Cause:` + JSON.stringify(error)); + return; + } + console.log(`Succeeded in getting systemTime.Data: ` + JSON.stringify(data)); +}); +``` ## systemTime.getCurrentTime8+ @@ -118,144 +114,139 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| +| Name| Type | Mandatory| Description | +| ------ | ------- | ---- | ------------------------- | +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds (ns).
- **false**: in milliseconds (ms).| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<number> | Promise used to return the time.| +| Type | Description | +| --------------------- | --------------------------- | +| Promise<number> | Promise used to return the time elapsed since the Unix epoch.| **Example** - ```js - systemTime.getCurrentTime().then((data) => { - console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); - }); - ``` - +```js +systemTime.getCurrentTime().then((data) => { + console.log(`Succeeded in getting systemTime.Data: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`Failed to get systemTime. Cause:` + JSON.stringify(error)); +}); +``` ## systemTime.getRealActiveTime8+ getRealActiveTime(isNano?: boolean, callback: AsyncCallback<number>): void -Obtains the time elapsed since system start, excluding the deep sleep time. This API uses an asynchronous callback to return the result. +Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Time **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| -| callback | AsyncCallback<number> | Yes| Callback used to return the time.| +| Name | Type | Mandatory| Description | +| -------- | ---------- | ---- | -------------------------- | +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds (ns).
- **false**: in milliseconds (ms).| +| callback | AsyncCallback<number> | Yes | Callback used to return the time.| **Example** - ```js - systemTime.getRealActiveTime(true, (error, data) => { - if (error) { - console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error)); - return; - } - console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); - }); - ``` - +```js +systemTime.getRealActiveTime(true, (error, data) => { + if (error) { + console.error(`Failed to get real active systemTime. Cause:` + JSON.stringify(error)); + return; + } + console.log(`Succeeded in getting real active systemTime. Data: ` + JSON.stringify(data)); +}); +``` ## systemTime.getRealActiveTime8+ getRealActiveTime(isNano?: boolean): Promise<number> -Obtains the time elapsed since system start, excluding the deep sleep time. This API uses a promise to return the result. +Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Time **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| +| Name| Type | Mandatory| Description | +| ------ | ------- | ---- | ----------------------------------- | +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds (ns).
- **false**: in milliseconds (ms).| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<number> | Promise used to return the time.| +| Type | Description | +| -------------- | -------------------------------- | +| Promise<number> | Promise used to return the time elapsed since system startup, excluding the deep sleep time.| **Example** - ```js - systemTime.getRealActiveTime().then((data) => { - console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error)); - }); - ``` - +```js +systemTime.getRealActiveTime().then((data) => { + console.log(`Succeeded in getting real active systemTime. Data: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`Failed to get real active systemTime. Cause:` + JSON.stringify(error)); +}); +``` ## systemTime.getRealTime8+ getRealTime(isNano?: boolean, callback: AsyncCallback<number>): void -Obtains the time elapsed since system start, including the deep sleep time. This API uses an asynchronous callback to return the result. +Obtains the time elapsed since system startup, including the deep sleep time. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Time **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| -| callback | AsyncCallback<number> | Yes| Callback used to return the time.| +| Name | Type | Mandatory| Description | +| -------- | --------------- | ---- | ------------------------------- | +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds (ns).
- **false**: in milliseconds (ms).| +| callback | AsyncCallback<number> | Yes | Callback used to return the time. | **Example** - ```js - systemTime.getRealTime(true, (error, data) => { - if (error) { - console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); - return; - } - console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); - }); - ``` - +```js +systemTime.getRealTime(true, (error, data) => { + if (error) { + console.error(`Failed to get real systemTime. Cause:` + JSON.stringify(error)); + return; + } + console.log(`Succeeded in getting real active systemTime. Data: ` + JSON.stringify(data)); +}); +``` ## systemTime.getRealTime8+ getRealTime(isNano?: boolean): Promise<number> -Obtains the time elapsed since system start, including the deep sleep time. This API uses a promise to return the result. +Obtains the time elapsed since system startup, including the deep sleep time. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Time **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| +| Name| Type | Mandatory| Description | +| ------ | ------- | ---- | ------------------------------- | +| isNano | boolean | No | Whether the time to return is in nanoseconds.<
- **true**: in nanoseconds (ns).
- **false**: in milliseconds (ms).| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<number> | Promise used to return the time.| +| Type | Description | +| --------------------- | ------------------------------- | +| Promise<number> | Promise used to return the time elapsed since system startup, including the deep sleep time.| **Example** - ```js - systemTime.getRealTime().then((data) => { - console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); - }); - ``` - +```js +systemTime.getRealTime().then((data) => { + console.log(`Succeeded in getting real active systemTime. Data: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`Failed to get real systemTime. Cause:` + JSON.stringify(error)); +}); +``` ## systemTime.setDate @@ -269,24 +260,23 @@ Sets the system date. This API uses an asynchronous callback to return the resul **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| date | Date | Yes| Target date to set.| -| callback | AsyncCallback<void> | Yes| Callback used to process the received return value.| +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | --------------------- | +| date | Date | Yes | Target date to set. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js - var data = new Date("October 13, 2020 11:13:00"); - systemTime.setDate(data,(error, data) => { - if (error) { - console.error('failed to systemTime.setDate because ' + JSON.stringify(error)); - return; - } - console.info('systemTime.setDate success data : ' + JSON.stringify(data)); - }); - ``` - +```js +let data = new Date("October 13, 2020 11:13:00"); +systemTime.setDate(data,(error) => { + if (error) { + console.error('Failed to set systemDate. Cause: ' + JSON.stringify(error)); + return; +} + console.info('Succeeded in setting systemDate.'); +}); +``` ## systemTime.setDate @@ -300,27 +290,26 @@ Sets the system date. This API uses a promise to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| date | Date | Yes| Target date to set.| +| Name| Type| Mandatory| Description | +| ------ | ---- | ---- | ---------- | +| date | Date | Yes | Target date to set.| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<void> | Promise used to return the result.| +| Type | Description | +| ------------------- | -------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - var data = new Date("October 13, 2020 11:13:00"); - systemTime.setDate(data).then((value) => { - console.log(`systemTime.setDate success data : ` + JSON.stringify(value)); - }).catch((error) => { - console.error(`failed to systemTime.setDate because: ` + JSON.stringify(error)); - }); - ``` - +```js +let data = new Date("October 13, 2020 11:13:00"); +systemTime.setDate(data).then(() => { + console.log('Succeeded in setting systemDate.'); +}).catch((error) => { + console.error(`Failed to set systemDate. Cause: ` + JSON.stringify(error)); +}); +``` ## systemTime.getDate8+ @@ -332,47 +321,45 @@ Obtains the current system date. This API uses an asynchronous callback to retur **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<Date> | Yes| Callback used to return the current system date.| +| Name | Type | Mandatory| Description | +| -------- | -------------- | ---- | --------------------- | +| callback | AsyncCallback<Date> | Yes | Callback used to return the current system date.| **Example** - ```js - systemTime.getDate((error, data) => { - if (error) { - console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); - return; - } - console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); - }); - ``` - +```js +systemTime.getDate((error, data) => { + if (error) { + console.error(`Failed to get systemDate. Cause: ` + JSON.stringify(error)); + return; + } + console.log(`Succeeded in getting systemDate. Data: ` + JSON.stringify(data)); +}); +``` ## systemTime.getDate8+ getDate(): Promise<Date> -Obtains the current system date. This API uses a promise to return the result. +Obtains the current system date. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Time **Return value** -| Type| Description| -| -------- | -------- | +| Type | Description | +| ------------------- | ----------------------------------------- | | Promise<Date> | Promise used to return the current system date.| **Example** - ```js - systemTime.getDate().then((data) => { - console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); - }); - ``` - +```js +systemTime.getDate().then((data) => { + console.log(`Succeeded in getting systemDate. Data: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`Failed to get systemDate. Cause: ` + JSON.stringify(error)); +}); +``` ## systemTime.setTimezone @@ -386,23 +373,22 @@ Sets the system time zone. This API uses an asynchronous callback to return the **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| timezone | string | Yes| System time zone to set.| -| callback | AsyncCallback<void> | Yes| Callback used to process the received return value.| +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------------------------- | +| timezone | string | Yes | System time zone to set. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js - systemTime.setTimezone('Asia/Shanghai', (error, data) => { - if (error) { - console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error)); - return; - } - console.info('SystemTimePlugin systemTime.setTimezone success data : ' + JSON.stringify(data)); - }); - ``` - +```js +systemTime.setTimezone('Asia/Shanghai', (error) => { + if (error) { + console.error('Failed to set systemTimeZone. Cause: ' + JSON.stringify(error)); + return; + } + console.info('Succeeded in setting systemTimeZone.'); +}); +``` ## systemTime.setTimezone @@ -416,26 +402,25 @@ Sets the system time zone. This API uses a promise to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| timezone | string | Yes| System time zone to set.| +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ---------- | +| timezone | string | Yes | System time zone to set.| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<void> | Promise used to return the result.| +| Type | Description | +| ------------------- | -------------------- | +| Promise<void> | Promise that returns no value.| **Example** - ```js - systemTime.setTimezone('Asia/Shanghai').then((data) => { - console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to systemTime.setTimezone because: ` + JSON.stringify(error)); - }); - ``` - +```js +systemTime.setTimezone('Asia/Shanghai').then(() => { + console.log('Succeeded in setting systemTimeZone.'); +}).catch((error) => { + console.error(`Failed to set systemTimeZone. Cause: ` + JSON.stringify(error)); +}); +``` ## systemTime.getTimezone8+ @@ -447,22 +432,21 @@ Obtains the system time zone. This API uses an asynchronous callback to return t **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<string> | Yes| Callback used to return the system time zone.| +| Name | Type | Mandatory| Description | +| -------- | --------- | ---- | ------------------------ | +| callback | AsyncCallback<string> | Yes | Callback used to return the system time zone.| **Example** - ```js - systemTime.getTimezone((error, data) => { - if (error) { - console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); - return; - } - console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); - }); - ``` - +```js +systemTime.getTimezone((error, data) => { + if (error) { + console.error(`Failed to get systemTimeZone. Cause: ` + JSON.stringify(error)); + return; + } + console.log(`Succeeded in getting systemTimeZone. Data: ` + JSON.stringify(data)); +}); +``` ## systemTime.getTimezone8+ @@ -474,16 +458,16 @@ Obtains the system time zone. This API uses a promise to return the result. **Return value** -| Type| Description| -| -------- | -------- | +| Type | Description | +| --------------------- | ------------------------------------- | | Promise<string> | Promise used to return the system time zone.| **Example** - ```js - systemTime.getTimezone().then((data) => { - console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); - }); - ``` +```js +systemTime.getTimezone().then((data) => { + console.log(`Succeeded in getting systemTimeZone. Data: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`Failed to get systemTimeZone. Cause: ` + JSON.stringify(error)); +}); +``` diff --git a/en/application-dev/reference/arkui-js/js-components-container-dialog.md b/en/application-dev/reference/arkui-js/js-components-container-dialog.md index dba6b21f822e4c07faef3e40c2cbed79f2d2b3b5..a37adca994facb60950bc6d072541108509680c8 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-dialog.md +++ b/en/application-dev/reference/arkui-js/js-components-container-dialog.md @@ -1,61 +1,67 @@ # dialog -The **<dialog>** component is a custom pop-up container. +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + +The **\** component is a custom dialog box. ## Required Permissions None -## Child Components -A single child component is supported. +## Child Components -## Attributes +This component supports only one child component. -In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. +## Attributes +In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported. -| Name | Type | Default Value | Mandatory | Description | -| --------------------- | ------- | ------------- | --------- | ---------------------------------- | -| dragable7+ | boolean | false | No | Whether the pop-up can be dragged. | +| Name | Type | Default Value | Mandatory | Description | +| --------------------- | ------- | ----- | ---- | ------------ | +| dragable7+ | boolean | false | No | Whether the dialog box can be dragged.| -> ![img](https://gitee.com/openharmony/docs/raw/master/en/application-dev/public_sys-resources/icon-note.gif) **NOTE:** +> **NOTE** > -> - The **<dialog>** component does not support the **focusable** and **click-effect** attributes. +> The **\** component does not support the **focusable** and **click-effect** attributes. + ## Styles -Only the **width**, **height**, **margin**, **margin-[left|top|right|bottom]**, and **margin-[start|end]** styles in [Universal Styles](js-components-common-styles.md) are supported. +Only the **width**, **height**, **margin**, **margin-[left|top|right|bottom]**, and **margin-[start|end]** styles in [Universal Styles](../arkui-js/js-components-common-styles.md) are supported. -## Events -Events in [Universal Events](js-components-common-events.md) are not supported. The following table lists the supported event. +## Events +The following events are supported. The [universal events](../arkui-js/js-components-common-events.md) are not supported. +| Name | Parameter | Description | +| ------------------ | ---- | -------------------------- | +| cancel | - | Triggered when a user touches an area outside the dialog box to cancel the dialog box.| +| show7+ | - | Triggered when the dialog box is displayed. | +| close7+ | - | Triggered when the dialog box is closed. | -| Name | Parameter | Description | -| ------- | --------- | ------------------------------------------------------------ | -| cancel | - | Triggered when a user taps a non-dialog area to cancel the pop-up. | -| show7+ | - | Triggered when the pop-up is displayed. | -| close7+ | - | Triggered when the pop-up is closed. | ## Methods -Methods in [Universal Methods](js-components-common-methods.md) are not supported. The following table lists the supported methods. - +The following methods are supported. The [universal methods](../arkui-js/js-components-common-methods.md) are not supported. +| Name | Parameter | Description | +| ----- | ---- | ------ | +| show | - | Shows a dialog box.| +| close | - | Close the dialog box.| -| Name | Parameter | Description | -| ----- | --------- | -------------------- | -| show | - | Shows a dialog box. | -| close | - | Closes a dialog box. | +> **NOTE** +> +> Attributes and styles of a **\** component cannot be dynamically updated. -> ![img](https://gitee.com/openharmony/docs/raw/master/en/application-dev/public_sys-resources/icon-note.gif) **NOTE:** Attributes and styles of a **\** component cannot be dynamically updated. -## Example Code +## Example -``` +```html
@@ -73,6 +79,9 @@ Methods in [Universal Methods](js-components-common-methods.md) are not supporte
+``` + +```css /* xxx.css */ .doc-page { flex-direction: column; @@ -119,30 +128,33 @@ Methods in [Universal Methods](js-components-common-methods.md) are not supporte background-color: #F2F2F2; text-color: #0D81F2; } +``` + +```js // xxx.js import prompt from '@system.prompt'; export default { - showDialog(e) { + showDialog() { this.$element('simpledialog').show() }, - cancelDialog(e) { + cancelDialog() { prompt.showToast({ message: 'Dialog cancelled' }) }, - cancelSchedule(e) { + cancelSchedule() { this.$element('simpledialog').close() prompt.showToast({ message: 'Successfully cancelled' }) }, - setSchedule(e) { + setSchedule() { this.$element('simpledialog').close() prompt.showToast({ message: 'Successfully confirmed' }) }, - doubleclick(e){ + doubleclick(){ prompt.showToast({ message: 'doubleclick' }) @@ -150,4 +162,4 @@ export default { } ``` -![img](figures/4.gif) \ No newline at end of file +![4](figures/4.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-badge.md b/en/application-dev/reference/arkui-ts/ts-container-badge.md index 2bc7c61001496b4145f7c7266a27d90f65e87813..f3dd7c6710648b165208f64c7147e6f7a9c0758a 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-badge.md +++ b/en/application-dev/reference/arkui-ts/ts-container-badge.md @@ -24,7 +24,7 @@ Create a badge. | count | number | Yes| - | Number of notifications.| | position | [BadgePosition](#badgeposition) | No| BadgePosition.RightTop | Position to display the badge relative to the parent component.| | maxCount | number | No| 99 | Maximum number of notifications. When the maximum number is reached, only **maxCount+** is displayed.| -| style | [BadgeStyle](#badgestyle) | Yes| - | Style of the badge, including the font color, font size, badge color, and badge size. | +| style | [BadgeStyle](#badgestyle) | Yes| - | Style of the badge, including the font color, font size, badge color, and badge size.| **Method 2**: Badge(value: {value: string, position?: BadgePosition, style: BadgeStyle}) @@ -36,7 +36,7 @@ Creates a badge based on the given string. | -------- | -------- | -------- | -------- | -------- | | value | string | Yes| - | Prompt content.| | position | [BadgePosition](#badgeposition) | No| BadgePosition.RightTop | Position to display the badge relative to the parent component.| -| style | [BadgeStyle](#badgestyle) | Yes| - | Style of the badge, including the font color, font size, badge color, and badge size. | +| style | [BadgeStyle](#badgestyle) | Yes| - | Style of the badge, including the font color, font size, badge color, and badge size.| ## BadgePosition @@ -47,12 +47,13 @@ Creates a badge based on the given string. | Left | The badge is vertically centered on the left of the parent component.| ## BadgeStyle -| Name| Type| Mandatory| Default Value| Description| -| -------- | -------- | -------- | -------- | -------- | -| color | [ResourceColor](ts-types.md#resourcecolor) | No| Color.White | Font color. | -| fontSize | number \| string | No| 10 | Font size. | -| badgeSize | number \| string | Yes| - | Badge size.| -| badgeColor | [ResourceColor](ts-types.md#resourcecolor) | No| Color.Red | Badge color.| + +| Name | Type | Mandatory| Default Value | Description | +| ---------- | ------------------------------------------ | ---- | ----------- | ------------------------------------------- | +| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color.White | Font color. | +| fontSize | number \| string | No | 10 | Font size, in vp. | +| badgeSize | number \| string | No | 16 | Badge size, in vp. This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.| +| badgeColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color.Red | Badge color. | ## Example