UI Decorator Overview
The following table lists the common decorators in ArkUI.
| Common Decorator | Description |
|---|---|
| @Require | Validates constructor input parameters. |
| @Builder | Customizes builder function. |
| @LocalBuilder | Maintains the component relationship. |
| @BuilderParam | References the @Builder function. |
| @Styles | Defines the component reuse style. |
| @Extend | Defines the extension component style. |
| @AnimatableExtend | Defines animatable attributes. |
| @Env | Environment variables. |
The following table lists the V1 state management decorators in ArkUI.
| V1 State Management Decorator | Description |
|---|---|
| @State | Basic state variable. |
| @Prop | Establishes one-way synchronization between the parent and child states. |
| @Link | Establishes two-way synchronization between the parent and child states. |
| @ObjectLink | Observes the changes of nested class object attributes. |
| @Provide | Establishes two-way synchronization with the child states. |
| @Consume | Establishes two-way synchronization with the ancestor state. |
| @Watch | Observes state variable changes. |
| @StorageLink | Establishes two-way data synchronization with the corresponding attribute in the AppStorage. |
| @StorageProp | Establishes two-way data synchronization with the corresponding attribute in the AppStorage. |
| @LocalStorageLink | Establishes two-way data synchronization with the corresponding attribute in the LocalStorage. |
| @LocalStorageProp | Establishes one-way data synchronization with the corresponding attribute in the LocalStorage. |
| @Observed | Marks the class observable. |
| @Track | Class object attribute update. |
| @Reusable | Marks the component reusable. |
The following table lists the V2 state management decorators in ArkUI.
| V2 State Management Decorator | Description |
|---|---|
| @Local | Internal status of a component. |
| @Param | External input of the component. |
| @Once | Synchronizes initialization once. |
| @Event | Standardizes the component output. |
| @Provider | Establishes two-way synchronization with the child states. |
| @Consumer | Establishes two-way synchronization with the ancestor states. |
| @Monitor | Observes state variable changes. |
| @Computed | Computed attributes. |
| @ObservedV2 | Marks the class observable. |
| @Trace | Marks the class attribute observable. |
| @Type | Marks the types of the class attributes. |
| @ReusableV2 | Marks the component reusable. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 arkts-new-makeObserved
openharmony 鸿蒙 arkts-new-param
openharmony 鸿蒙 arkts-state-management-introduce
openharmony 鸿蒙 properly-use-state-management-to-develope
openharmony 鸿蒙 arkts-new-persistencev2
openharmony 鸿蒙 arkts-v1-v2-migration-application
openharmony 鸿蒙 arkts-v1-v2-migration-reusable
openharmony 鸿蒙 arkts-page-custom-components-lifecycle