“e0d07cf1ee7963913b56283fea4276714c8e67e0”上不存在“git@gitcode.net:zhangbin19901019/gpt-vue_02.git”
未验证 提交 dd13357b 编写于 作者: O openharmony_ci 提交者: Gitee

!23696 Rectify the arkts syntax 3 on monthly

Merge pull request !23696 from 189******51/monthly_20230815
...@@ -64,27 +64,27 @@ ...@@ -64,27 +64,27 @@
- \@Extend装饰的方法的参数可以为function,作为Event事件的句柄。 - \@Extend装饰的方法的参数可以为function,作为Event事件的句柄。
```ts ```ts
@Extend(Text) function makeMeClick(onClick: () => void) { @Extend(Text) function makeMeClick(onClick: () => void) {
.backgroundColor(Color.Blue) .backgroundColor(Color.Blue)
.onClick(onClick) .onClick(onClick)
} }
@Entry @Entry
@Component @Component
struct FancyUse { struct FancyUse {
@State label: string = 'Hello World'; @State label: string = 'Hello World';
onClickHandler() { onClickHandler() {
this.label = 'Hello ArkUI'; this.label = 'Hello ArkUI';
} }
build() { build() {
Row({ space: 10 }) { Row({ space: 10 }) {
Text(`${this.label}`) Text(`${this.label}`)
.makeMeClick(this.onClickHandler.bind(this)) .makeMeClick(this.onClickHandler)
}
} }
} }
}
``` ```
- \@Extend的参数可以为[状态变量](arkts-state-management-overview.md),当状态变量改变时,UI可以正常的被刷新渲染。 - \@Extend的参数可以为[状态变量](arkts-state-management-overview.md),当状态变量改变时,UI可以正常的被刷新渲染。
......
...@@ -346,7 +346,7 @@ struct ViewB { ...@@ -346,7 +346,7 @@ struct ViewB {
(item: ClassA) => { (item: ClassA) => {
ViewA({ label: `#${item.id}`, a: item }) ViewA({ label: `#${item.id}`, a: item })
}, },
(item: ClassA) => item.id.toString() (item: ClassA): string => item.id.toString()
) )
// 使用@State装饰的数组的数组项初始化@ObjectLink,其中数组项是被@Observed装饰的ClassA的实例 // 使用@State装饰的数组的数组项初始化@ObjectLink,其中数组项是被@Observed装饰的ClassA的实例
ViewA({ label: `ViewA this.arrA[first]`, a: this.arrA[0] }) ViewA({ label: `ViewA this.arrA[first]`, a: this.arrA[0] })
......
...@@ -264,7 +264,7 @@ struct ParentComponent { ...@@ -264,7 +264,7 @@ struct ParentComponent {
```ts ```ts
@Component @Component
struct Child { struct Child {
@Prop value: number; @Prop value: number = 0;
build() { build() {
Text(`${this.value}`) Text(`${this.value}`)
...@@ -288,10 +288,10 @@ struct Index { ...@@ -288,10 +288,10 @@ struct Index {
Divider().height(5) Divider().height(5)
ForEach(this.arr, ForEach(this.arr,
item => { (item: void) => {
Child({value: item}) Child({value: item})
}, },
item => item.toString() (item: string) => item.toString()
) )
Text('replace entire arr') Text('replace entire arr')
.fontSize(50) .fontSize(50)
...@@ -419,7 +419,7 @@ class Book { ...@@ -419,7 +419,7 @@ class Book {
@Component @Component
struct ReaderComp { struct ReaderComp {
@Prop book: Book; @Prop book: Book = new Book();
build() { build() {
Row() { Row() {
...@@ -442,10 +442,10 @@ struct Library { ...@@ -442,10 +442,10 @@ struct Library {
ReaderComp({ book: this.allBooks[2] }) ReaderComp({ book: this.allBooks[2] })
Divider() Divider()
Text('Books on loaan to a reader') Text('Books on loaan to a reader')
ForEach(this.allBooks, book => { ForEach(this.allBooks, (book: void) => {
ReaderComp({ book: book }) ReaderComp({ book: book })
}, },
book => book.id) (book: number): number => book.id)
Button('Add new') Button('Add new')
.onClick(() => { .onClick(() => {
this.allBooks.push(new Book("The C++ Standard Library", 512)); this.allBooks.push(new Book("The C++ Standard Library", 512));
......
...@@ -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.
先完成此消息的编辑!
想要评论请 注册