提交 5278e32a 编写于 作者: E ester.zhou

update docs

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
无相关合并请求
# Emitter
> **NOTE**<br>
The **Emitter** module provides APIs for sending and processing in-process events, including the APIs for processing events that are subscribed to in persistent or one-shot manner, unsubscribing from events, and emitting events to the event queue.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7.
## Modules to Import
......@@ -17,12 +20,14 @@ None
Enumerates the event emit priority levels.
| Name | Value | Description |
| --------- | ---- | ------------------------------------------------- |
| IMMEDIATE | 0 | The event will be emitted immediately.<br>**System capability**: SystemCapability.Notification.Emitter |
| HIGH | 1 | The event will be emitted before low-priority events.<br>**System capability**: SystemCapability.Notification.Emitter |
| LOW | 2 | The event will be emitted before idle-priority events. By default, an event is in LOW priority.<br>**System capability**: SystemCapability.Notification.Emitter |
| IDLE | 3 | The event will be emitted after all the other events.<br>**System capability**: SystemCapability.Notification.Emitter |
**System capability**: SystemCapability.Notification.Emitter
| Name | Value | Description |
| --------- | ---- | ------------------------------------------------- |
| IMMEDIATE | 0 | The event will be emitted immediately. |
| HIGH | 1 | The event will be emitted before low-priority events. |
| LOW | 2 | The event will be emitted before idle-priority events. By default, an event is in LOW priority. |
| IDLE | 3 | The event will be emitted after all the other events. |
## emitter.on
......@@ -34,10 +39,10 @@ Subscribes to an event in persistent manner. This API uses a callback to return
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ----------------------------------- | ---- | ------------------------ |
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. |
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. |
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | ------------------------ |
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. |
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event.|
**Example**
......@@ -61,10 +66,10 @@ Subscribes to an event in one-shot manner and unsubscribes from it after the eve
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ----------------------------------- | ---- | ------------------------ |
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. |
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. |
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | ------------------------ |
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. |
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event.|
**Example**
......@@ -88,9 +93,9 @@ Unsubscribes from an event.
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ------ |
| eventId | number | Yes | Event ID. |
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------ |
| eventId | number | Yes | Event ID.|
**Example**
......@@ -108,10 +113,10 @@ Emits an event to the event queue.
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------------------------- | ---- | -------------- |
| event | [InnerEvent](#innerevent) | Yes | Event to emit. |
| data | [EventData](#eventdata) | No | Data carried by the event. |
| Name| Type | Mandatory| Description |
| ------ | ------------------------- | ---- | -------------- |
| event | [InnerEvent](#innerevent) | Yes | Event to emit. |
| data | [EventData](#eventdata) | No | Data carried by the event.|
**Example**
......@@ -130,17 +135,21 @@ emitter.emit(innerEvent, eventData);
## InnerEvent
Describes an intra-process event.
Describes an in-process event.
| Name | Type | Readable | Writable | Description |
| -------- | ------------------------------- | ---- | ---- | ---------------------------------- |
| eventId | number | Yes | Yes | Event ID, which is used to identify an event.<br>**System capability**: SystemCapability.Notification.Emitter |
| priority | [EventPriority](#eventpriority) | Yes | Yes | Emit priority of the event.<br>**System capability**: SystemCapability.Notification.Emitter |
**System capability**: SystemCapability.Notification.Emitter
| Name | Type | Readable| Writable| Description |
| -------- | ------------------------------- | ---- | ---- | ---------------------------------- |
| eventId | number | Yes | Yes | Event ID, which is used to identify an event.|
| priority | [EventPriority](#eventpriority) | Yes | Yes | Emit priority of the event. |
## EventData
Describes the data passed in the event.
| Name | Type | Readable | Writable | Description |
| ---- | ------------------ | ---- | ---- | -------------- |
| data | [key: string]: any | Yes | Yes | Data carried by the event. The data type can be String, Integer, or Boolean.<br>**System capability**: SystemCapability.Notification.Emitter |
**System capability**: SystemCapability.Notification.Emitter
| Name| Type | Readable| Writable| Description |
| ---- | ------------------ | ---- | ---- | -------------- |
| data | [key: string]: any | Yes | Yes | Data carried by the event. The data type can be String, Integer, or Boolean.|
# Button
The **\<Button>** component can be used to create different types of buttons.
> **NOTE**<br>
> **NOTE**
>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;Button&gt;** component represents a component that can trigger actions.
## Required Permissions
None
......@@ -30,15 +29,15 @@ Supported
| stateEffect | boolean | No | true | Whether to enable the state switchover effect when a button is pressed. When the state is set to **false**, the state switchover effect is disabled. |
- Button(label?: string, options?: { type?: ButtonType, stateEffect?: boolean })
- Button(label?: ResourceStr, options?: { type?: ButtonType, stateEffect?: boolean })
Creates a button component based on text content. In this case, the **&lt;Button&gt;** component cannot contain child components.
Creates a button component based on text content. In this case, the **\<Button>** component cannot contain child components.
**Table 2** value parameters
**Table 2** Parameters
| Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
| label | string | No | - | Button text. |
| label | [ResourceStr](../../ui/ts-types.md) | No | - | Button text. |
| options | Object | No | - | For details, see the **options** parameters. |
......@@ -54,8 +53,8 @@ Supported
| Name | Description |
| -------- | -------- |
| Capsule | Capsule-type button (the round corner is half of the height by default). |
| Circle | Circle button. |
| Normal | Normal button (without rounded corners by default). |
| Circle | Circle button. |
| Normal | Normal button (without rounded corners by default). |
> **NOTE**
> - The rounded corner of a button is set by using [Border](ts-universal-attributes-border.md). (The rounded corner cannot be set by using a border API.)
......@@ -67,7 +66,8 @@ Supported
## Example
```
```ts
// xxx.ets
@Entry
@Component
struct ButtonExample {
......@@ -78,6 +78,7 @@ struct ButtonExample {
Button('Ok', { type: ButtonType.Normal, stateEffect: true }).borderRadius(8).backgroundColor(0x317aff).width(90)
Button({ type: ButtonType.Normal, stateEffect: true }) {
Row() {
// You are advised to reference an image by using $r to create a Resource object.
Image($r('app.media.loading')).width(20).height(20).margin({ left: 12 })
Text('loading').fontSize(12).fontColor(0xffffff).margin({ left: 5, right: 12 })
}.alignItems(VerticalAlign.Center)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部