From 4638213b7ad87e2de7e9ae992c7cac2aef868da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Mon, 4 Sep 2023 08:11:29 +0000 Subject: [PATCH] update zh-cn/application-dev/quick-start/arkts-state-management-best-practices.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../arkts-state-management-best-practices.md | 71 ++++++++++--------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/zh-cn/application-dev/quick-start/arkts-state-management-best-practices.md b/zh-cn/application-dev/quick-start/arkts-state-management-best-practices.md index 2136d30a22..62657f74ad 100644 --- a/zh-cn/application-dev/quick-start/arkts-state-management-best-practices.md +++ b/zh-cn/application-dev/quick-start/arkts-state-management-best-practices.md @@ -350,44 +350,43 @@ class ClassB extends ClassA { @Component struct ViewClassC { - @ObjectLink c : ClassC; - build() { - Column({space:10}) { - Text(`c: ${this.c.getC()}`) - Button("Change C") - .onClick(() => { - this.c.setC(this.c.getC()+1); - }) - } - } + @ObjectLink c : ClassC; + build() { + Column({space:10}) { + Text(`c: ${this.c.getC()}`) + Button("Change C") + .onClick(() => { + this.c.setC(this.c.getC()+1); + }) + } } @Entry @Component struct MyView { - @State b : ClassB = new ClassB(10, 20, 30); - - build() { - Column({space:10}) { - Text(`a: ${this.b.a}`) - Button("Change ClassA.a") - .onClick(() => { - this.b.a +=1; - }) - - Text(`b: ${this.b.b}`) - Button("Change ClassB.b") - .onClick(() => { - this.b.b += 1; - }) - - ViewClassC({c: this.b.c}) // Text(`c: ${this.b.c.c}`)的替代写法 - Button("Change ClassB.ClassC.c") - .onClick(() => { - this.b.c.c += 1; - }) - } - } + @State b : ClassB = new ClassB(10, 20, 30); + + build() { + Column({space:10}) { + Text(`a: ${this.b.a}`) + Button("Change ClassA.a") + .onClick(() => { + this.b.a +=1; + }) + + Text(`b: ${this.b.b}`) + Button("Change ClassB.b") + .onClick(() => { + this.b.b += 1; + }) + + ViewClassC({c: this.b.c}) // Text(`c: ${this.b.c.c}`)的替代写法 + Button("Change ClassB.ClassC.c") + .onClick(() => { + this.b.c.c += 1; + }) + } + } } ``` @@ -1118,6 +1117,12 @@ class ClassE { this.d = d; } } + +``` + +以下组件层次结构呈现的是@Prop嵌套场景的数据结构。 + +```ts @Entry @Component struct Parent { -- GitLab