未验证 提交 a676e06f 编写于 作者: O openharmony_ci 提交者: Gitee

!17900 add description of observed

Merge pull request !17900 from yfwang6/state2
...@@ -122,7 +122,7 @@ struct ParentComponent { ...@@ -122,7 +122,7 @@ struct ParentComponent {
- 不支持静态函数。 - 不支持静态函数。
- 成员函数的访问始终是私有的,仅能定义private。定义访问权限是可选的,其他访问权限会带来语法错误 - 成员函数的访问始终是私有的。
自定义组件可以包含成员变量,成员变量具有以下约束: 自定义组件可以包含成员变量,成员变量具有以下约束:
......
...@@ -106,6 +106,10 @@ ArkUI提供了多种装饰器,通过使用这些装饰器,状态变量不仅 ...@@ -106,6 +106,10 @@ ArkUI提供了多种装饰器,通过使用这些装饰器,状态变量不仅
- \@ObjectLink:\@ObjectLink装饰的变量接收\@Observed装饰的class的实例,应用于观察多层嵌套场景,和父组件的数据源构建双向同步。 - \@ObjectLink:\@ObjectLink装饰的变量接收\@Observed装饰的class的实例,应用于观察多层嵌套场景,和父组件的数据源构建双向同步。
> **说明:**
>
> 仅[\@Observed/\@ObjectLink](arkts-observed-and-objectlink.md)可以观察嵌套场景,其他的状态变量仅能观察第一层,详情见各个装饰器章节的“观察变化和行为表现”小节。
[管理应用拥有的状态](arkts-application-state-management-overview.md),即图中Application级别的状态管理: [管理应用拥有的状态](arkts-application-state-management-overview.md),即图中Application级别的状态管理:
......
...@@ -231,11 +231,11 @@ struct MyComponent { ...@@ -231,11 +231,11 @@ struct MyComponent {
Text(`${this.title.value}`) Text(`${this.title.value}`)
Button(`Click to change title`).onClick(() => { Button(`Click to change title`).onClick(() => {
// @State变量的更新将触发上面的Text组件内容更新 // @State变量的更新将触发上面的Text组件内容更新
this.title.value = this.title.value === 'Hello ArkUI' ? 'Hello World' : 'HelloArkUI'; this.title.value = this.title.value === 'Hello ArkUI' ? 'Hello World' : 'Hello ArkUI';
}) })
Button(`Click to increase count=${this.count}`).onClick(() => { Button(`Click to increase count=${this.count}`).onClick(() => {
// @State变量的更新将触发上面的Text组件内容更新 // @State变量的更新将触发该Button组件的内容更新
this.count += this.increaseBy; this.count += this.increaseBy;
}) })
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册