| contentTimeout | [Config](#config)\<number>| Yes| Yes| Recommended duration for content display. The value ranges from 0 to 5000, in milliseconds.|
| contentTimeout | [Config](#config)\<number>| Yes| Yes| Recommended duration for content display. The value ranges from 0 to 5000, in milliseconds.|
| animationOff | [Config](#config)\<boolean>| Yes| Yes| Whether to enable animation.|
| animationOff | [Config](#config)\<boolean>| Yes| Yes| Whether to enable animation.|
| brightnessDiscount | [Config](#config)\<number>| Yes| Yes| Brightness discount. The value ranges from 0 to 1.0.|
| brightnessDiscount | [Config](#config)\<number>| Yes| Yes| Brightness discount. The value ranges from 0 to 1.0.|
...
@@ -163,7 +163,7 @@ Adds a listener for changes in the list of enabled accessibility extension abili
...
@@ -163,7 +163,7 @@ Adds a listener for changes in the list of enabled accessibility extension abili
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating that the changes in the list of enabled accessibility extension abilities.|
| type | string | Yes| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating the changes in the list of enabled accessibility extension abilities. |
| callback | Callback<void> | Yes| Callback invoked when the list of enabled accessibility extension abilities changes.|
| callback | Callback<void> | Yes| Callback invoked when the list of enabled accessibility extension abilities changes.|
**Example**
**Example**
...
@@ -186,7 +186,7 @@ Cancels the listener for changes in the list of enabled accessibility extension
...
@@ -186,7 +186,7 @@ Cancels the listener for changes in the list of enabled accessibility extension
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | No| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating that the changes in the list of enabled accessibility extension abilities.|
| type | string | No| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating the changes in the list of enabled accessibility extension abilities. |
| callback | Callback<void> | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
| callback | Callback<void> | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
The **deviceInfo** module provides product information.
> **NOTE**
> **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.
> 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.
The **@Builder** decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the **@Builder** decorator are the same as those of the [build Function](ts-function-build.md).
The **@Builder** decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. If a custom component is used in the **@Builder** decorated method, this component will be re-created each time the method is invoked. The functionality and syntax of the **@Builder** decorator are the same as those of the **build** function.
```ts
```ts
// xxx.ets
// xxx.ets
@Component
structCompB{
@StateCompValue:string='';
aboutToAppear(){
console.info('CompB aboutToAppear.');
}
aboutToDisappear(){
console.info('CompB aboutToDisappear.');
}
build(){
Column(){
Button(this.CompValue);
}
}
}
@Entry
@Entry
@Component
@Component
structCompA{
structCompA{
size1:number=100;
size1:number=100;
@StateCompValue1:string="Hello,CompValue1";
@StateCompValue2:string="Hello,CompValue2";
@StateCompValue3:string="Hello,CompValue3";
// Use a custom component in the @Builder decorated method.
@BuilderCompC(value:string){
CompB({CompValue:value});
}
@BuilderSquareText(label:string){
@BuilderSquareText(label:string){
Text(label)
Text(label)
...
@@ -35,7 +63,16 @@ struct CompA {
...
@@ -35,7 +63,16 @@ struct CompA {
}
}
.width(2*this.size1)
.width(2*this.size1)
.height(1*this.size1)
.height(1*this.size1)
this.RowOfSquareTexts("C","D")
this.RowOfSquareTexts("C","D")
Column(){
// Use the custom component in the @Builder decorated method three times.
this.CompC(this.CompValue1);
this.CompC(this.CompValue2);
this.CompC(this.CompValue3);
}
.width(2*this.size1)
.height(2*this.size1)
}
}
.width(2*this.size1)
.width(2*this.size1)
.height(2*this.size1)
.height(2*this.size1)
...
@@ -99,7 +136,7 @@ struct CustomContainerUser {
...
@@ -99,7 +136,7 @@ struct CustomContainerUser {
}
}
```
```
### Component Initialization Through Trailing Closure
### Component Initialization Through Trailing Closure
In a custom component, use the **@BuilderParam** decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (`CustomComponent(){}`). You can consider a trailing closure as a container and add content to it. For example, you can add a component (`{Column(){Text("content")}`) to a trailing closure. The syntax of the closure is the same as that of [build](../ui/ts-function-build.md). In this scenario, the custom component has one and only one **@BuilderParam** decorated attribute.
In a custom component, use the **@BuilderParam** decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (`CustomComponent(){}`). You can consider a trailing closure as a container and add content to it. For example, you can add a component (`{Column(){Text("content")}`) to a trailing closure. The syntax of the closure is the same as that of the **build** function. In this scenario, the custom component has one and only one **@BuilderParam** decorated attribute.
Example: Add a **\<Column>** component and a click event to the closure, and call the **specificParam** method decorated by **@Builder** in the new **\<Column>** component. After the **\<Column>** component is clicked, the value of the component's `header` attribute will change to `changeHeader`. In addition, when the component is initialized, the content of the trailing closure will be assigned to the `closer` attribute decorated by **@BuilderParam**.
Example: Add a **\<Column>** component and a click event to the closure, and call the **specificParam** method decorated by **@Builder** in the new **\<Column>** component. After the **\<Column>** component is clicked, the value of the component's `header` attribute will change to `changeHeader`. In addition, when the component is initialized, the content of the trailing closure will be assigned to the `closer` attribute decorated by **@BuilderParam**.