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 538c27e9e0787af8ced563bef4f0076b6e856b1b..e4c7838e12ec0ce594ea78ebcbaaf1a9732f4eb6 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 @@ -346,7 +346,7 @@ struct ViewB { (item: ClassA) => { ViewA({ label: `#${item.id}`, a: item }) }, - (item: ClassA) => item.id.toString() + (item: ClassA): string => item.id.toString() ) // 使用@State装饰的数组的数组项初始化@ObjectLink,其中数组项是被@Observed装饰的ClassA的实例 ViewA({ label: `ViewA this.arrA[first]`, a: this.arrA[0] }) diff --git a/zh-cn/application-dev/quick-start/arkts-prop.md b/zh-cn/application-dev/quick-start/arkts-prop.md index 9250154d01eb42c8c6c56c47b30dc586621f0b00..12b19eac88c0acf63342cc0aeb93cab0f678044c 100644 --- a/zh-cn/application-dev/quick-start/arkts-prop.md +++ b/zh-cn/application-dev/quick-start/arkts-prop.md @@ -264,7 +264,7 @@ struct ParentComponent { ```ts @Component struct Child { - @Prop value: number; + @Prop value: number = 0; build() { Text(`${this.value}`) @@ -288,10 +288,10 @@ struct Index { Divider().height(5) ForEach(this.arr, - item => { + (item: void) => { Child({value: item}) }, - item => item.toString() + (item: string) => item.toString() ) Text('replace entire arr') .fontSize(50) diff --git a/zh-cn/application-dev/quick-start/arkts-rendering-control-best-practices.md b/zh-cn/application-dev/quick-start/arkts-rendering-control-best-practices.md index 5afba0367e9bf5c41c6d9c168faa95083e9d9faf..1b63c2c9a6872f991794d39f3d88dae16e7d61e6 100644 --- a/zh-cn/application-dev/quick-start/arkts-rendering-control-best-practices.md +++ b/zh-cn/application-dev/quick-start/arkts-rendering-control-best-practices.md @@ -22,10 +22,10 @@ struct Index { build() { Column() { ForEach(this.arr, - (item) => { + (item: void) => { Text(`Item ${item}`) }, - item => item.toString()) + (item: string) => item.toString()) Text('Add arr element') .fontSize(20) .onClick(()=>{ @@ -61,7 +61,7 @@ ForEach数据源更新时,数组项ID与原数组项ID重复不会重新创建 ```ts @Component struct Child { - @Prop value: number; + @Prop value: number = 0; build() { Text(`${this.value}`) .fontSize(50) @@ -83,10 +83,10 @@ struct Index { Child({ value: this.arr[2] }) Divider().height(5) ForEach(this.arr, - item => { + (item: number) => { Child({ value: item }) }, - item => item.toString() // 键值,标识id + (item: string) => item.toString() // 键值,标识id ) Text('Parent: replace entire arr') .fontSize(50)