未验证 提交 d476e8ac 编写于 作者: 1 189******51 提交者: Gitee

IssueNo: #I7XVG3:[新需求]: Rectify the arkts syntax 3

Description: Rectify the arkts syntax in arkts-rendering-control-best-practices.md
Sig: SIG_ApplicaitonFramework
Feature or Bugfix: Feature
Binary Source: No
Signed-off-by: N189******51 <lipeicheng5@huawei.com>
上级 b56ed38f
...@@ -22,10 +22,10 @@ struct Index { ...@@ -22,10 +22,10 @@ struct Index {
build() { build() {
Column() { Column() {
ForEach(this.arr, ForEach(this.arr,
(item) => { (item: void) => {
Text(`Item ${item}`) Text(`Item ${item}`)
}, },
item => item.toString()) (item: string) => item.toString())
Text('Add arr element') Text('Add arr element')
.fontSize(20) .fontSize(20)
.onClick(()=>{ .onClick(()=>{
...@@ -61,7 +61,7 @@ ForEach数据源更新时,数组项ID与原数组项ID重复不会重新创建 ...@@ -61,7 +61,7 @@ ForEach数据源更新时,数组项ID与原数组项ID重复不会重新创建
```ts ```ts
@Component @Component
struct Child { struct Child {
@Prop value: number; @Prop value: number = 0;
build() { build() {
Text(`${this.value}`) Text(`${this.value}`)
.fontSize(50) .fontSize(50)
...@@ -83,10 +83,10 @@ struct Index { ...@@ -83,10 +83,10 @@ struct Index {
Child({ value: this.arr[2] }) Child({ value: this.arr[2] })
Divider().height(5) Divider().height(5)
ForEach(this.arr, ForEach(this.arr,
item => { (item: number) => {
Child({ value: item }) Child({ value: item })
}, },
item => item.toString() // 键值,标识id (item: string) => item.toString() // 键值,标识id
) )
Text('Parent: replace entire arr') Text('Parent: replace entire arr')
.fontSize(50) .fontSize(50)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册