From 10abd9d976159868030ccffb7b24f2a2e9ad2a2b Mon Sep 17 00:00:00 2001 From: 189******51 Date: Wed, 30 Aug 2023 10:52:48 +0000 Subject: [PATCH] =?UTF-8?q?IssueNo:=20#I7X5WW:[=E6=96=B0=E9=9C=80=E6=B1=82?= =?UTF-8?q?]:=20Rectify=20the=20arkts=20syntax=20of=20qs=20on=20monthly=20?= =?UTF-8?q?Description:=20Rectify=20the=20arkts=20syntax=20of=20qs=20on=20?= =?UTF-8?q?monthly=20Sig:=20SIG=5FApplicaitonFramework=20Feature=20or=20Bu?= =?UTF-8?q?gfix:=20Feature=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 189******51 --- .../arkts-observed-and-objectlink.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/zh-cn/application-dev/quick-start/arkts-observed-and-objectlink.md b/zh-cn/application-dev/quick-start/arkts-observed-and-objectlink.md index d63149dcb8..538c27e9e0 100644 --- a/zh-cn/application-dev/quick-start/arkts-observed-and-objectlink.md +++ b/zh-cn/application-dev/quick-start/arkts-observed-and-objectlink.md @@ -126,7 +126,7 @@ this.b.a.c = 5 ```ts @Observed class DateClass extends Date { - constructor(args: any) { + constructor(args: number | string) { super(args) } } @@ -343,10 +343,10 @@ struct ViewB { build() { Column() { ForEach(this.arrA, - (item) => { + (item: ClassA) => { ViewA({ label: `#${item.id}`, a: item }) }, - (item) => item.id.toString() + (item: ClassA) => item.id.toString() ) // 使用@State装饰的数组的数组项初始化@ObjectLink,其中数组项是被@Observed装饰的ClassA的实例 ViewA({ label: `ViewA this.arrA[first]`, a: this.arrA[0] }) @@ -419,11 +419,11 @@ struct ItemPage { .width(100).height(100) ForEach(this.itemArr, - item => { + (item: string | Resource) => { Text(item) .width(100).height(100) }, - item => item + (item: string) => item ) } } @@ -439,14 +439,14 @@ struct IndexPage { ItemPage({ itemArr: this.arr[0] }) ItemPage({ itemArr: this.arr[1] }) ItemPage({ itemArr: this.arr[2] }) - Divider() + ForEach(this.arr, - itemArr => { + (itemArr: StringArray) => { ItemPage({ itemArr: itemArr }) }, - itemArr => itemArr[0] + (itemArr: string) => itemArr[0] ) Divider() @@ -454,7 +454,7 @@ struct IndexPage { Button('update') .onClick(() => { console.error('Update all items in arr'); - if (this.arr[0][0] !== undefined) { + if ((this.arr[0] as Array)[0] !== undefined) { // 正常情况下需要有一个真实的ID来与ForEach一起使用,但此处没有 // 因此需要确保推送的字符串是唯一的。 this.arr[0].push(`${this.arr[0].slice(-1).pop()}${this.arr[0].slice(-1).pop()}`); -- GitLab