提交 40ad21c4 编写于 作者: E ester.zhou

Update docs (11393)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 9fa935b8
# 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**<br>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&lt;void&gt;) : 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&lt;void&gt; | Yes| Callback used to process the received return value.|
| Name | Type | Mandatory| Description |
| -------- | ----------- | ---- | ---------------- |
| time | number | Yes | Timestamp to set, in milliseconds. |
| callback | AsyncCallback&lt;void&gt; | 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&lt;void&gt; | Promise used to return the result.|
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 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.getCurrentTime<sup>8+</sup>
......@@ -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&lt;number&gt; | Yes| Callback used to return the time.|
| Name | Type | Mandatory| Description |
| -------- | -------------- | ---- | ------------------ |
| isNano | boolean | No | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
| callback | AsyncCallback&lt;number&gt; | 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.getCurrentTime<sup>8+</sup>
......@@ -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.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the time.|
| Type | Description |
| --------------------- | --------------------------- |
| Promise&lt;number&gt; | 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.getRealActiveTime<sup>8+</sup>
getRealActiveTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): 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&lt;number&gt; | Yes| Callback used to return the time.|
| Name | Type | Mandatory| Description |
| -------- | ---------- | ---- | -------------------------- |
| isNano | boolean | No | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
| callback | AsyncCallback&lt;number&gt; | 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.getRealActiveTime<sup>8+</sup>
getRealActiveTime(isNano?: boolean): Promise&lt;number&gt;
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.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the time.|
| Type | Description |
| -------------- | -------------------------------- |
| Promise&lt;number&gt; | 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.getRealTime<sup>8+</sup>
getRealTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): 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&lt;number&gt; | Yes| Callback used to return the time.|
| Name | Type | Mandatory| Description |
| -------- | --------------- | ---- | ------------------------------- |
| isNano | boolean | No | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
| callback | AsyncCallback&lt;number&gt; | 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.getRealTime<sup>8+</sup>
getRealTime(isNano?: boolean): Promise&lt;number&gt;
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.<<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the time.|
| Type | Description |
| --------------------- | ------------------------------- |
| Promise&lt;number&gt; | 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&lt;void&gt; | Yes| Callback used to process the received return value.|
| Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | --------------------- |
| date | Date | Yes | Target date to set. |
| callback | AsyncCallback&lt;void&gt; | 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&lt;void&gt; | Promise used to return the result.|
| Type | Description |
| ------------------- | -------------------- |
| Promise&lt;void&gt; | 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.getDate<sup>8+</sup>
......@@ -332,47 +321,45 @@ Obtains the current system date. This API uses an asynchronous callback to retur
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Date&gt; | Yes| Callback used to return the current system date.|
| Name | Type | Mandatory| Description |
| -------- | -------------- | ---- | --------------------- |
| callback | AsyncCallback&lt;Date&gt; | 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.getDate<sup>8+</sup>
getDate(): Promise&lt;Date&gt;
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&lt;Date&gt; | 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&lt;void&gt; | Yes| Callback used to process the received return value.|
| Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | -------------------------- |
| timezone | string | Yes | System time zone to set. |
| callback | AsyncCallback&lt;void&gt; | 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&lt;void&gt; | Promise used to return the result.|
| Type | Description |
| ------------------- | -------------------- |
| Promise&lt;void&gt; | 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.getTimezone<sup>8+</sup>
......@@ -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&lt;string&gt; | Yes| Callback used to return the system time zone.|
| Name | Type | Mandatory| Description |
| -------- | --------- | ---- | ------------------------ |
| callback | AsyncCallback&lt;string&gt; | 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.getTimezone<sup>8+</sup>
......@@ -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&lt;string&gt; | 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));
});
```
# dialog
The **&lt;dialog&gt;** 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 **\<dialog>** 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 |
| --------------------- | ------- | ------------- | --------- | ---------------------------------- |
| dragable<sup>7+</sup> | boolean | false | No | Whether the pop-up can be dragged. |
| Name | Type | Default Value | Mandatory | Description |
| --------------------- | ------- | ----- | ---- | ------------ |
| dragable<sup>7+</sup> | 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 **&lt;dialog&gt;** component does not support the **focusable** and **click-effect** attributes.
> The **\<dialog>** 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.|
| show<sup>7+</sup> | - | Triggered when the dialog box is displayed. |
| close<sup>7+</sup> | - | 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 **\<dialog>** 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 **\<dialog>** component cannot be dynamically updated.
## Example Code
## Example
```
```html
<!-- xxx.hml -->
<div class="doc-page">
<div class="btn-div">
......@@ -73,6 +79,9 @@ Methods in [Universal Methods](js-components-common-methods.md) are not supporte
</div>
</dialog>
</div>
```
```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)
......@@ -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&nbsp;\|&nbsp;string | No| 10 | Font size. |
| badgeSize | number&nbsp;\|&nbsp;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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册