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

IssueNo: #I7X5WW:[新需求]: Rectify the arkts syntax of qs on monthly

Description: Rectify the arkts syntax of qs on monthly
Sig: SIG_ApplicaitonFramework
Feature or Bugfix: Feature
Binary Source: No
Signed-off-by: N189******51 <lipeicheng5@huawei.com>
上级 297ea4ea
...@@ -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("", 1);
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: Book) => {
ReaderComp({ book: book }) ReaderComp({ book: book })
}, },
book => book.id) (book: Book) => book.id.toString())
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));
...@@ -579,6 +579,26 @@ class ClassB { ...@@ -579,6 +579,26 @@ class ClassB {
以下组件层次结构呈现的是@Prop嵌套场景的数据结构。 以下组件层次结构呈现的是@Prop嵌套场景的数据结构。
```ts ```ts
// 以下是嵌套类对象的数据结构。
@Observed
class ClassA {
public title: string;
constructor(title: string) {
this.title = title;
}
}
@Observed
class ClassB {
public name: string;
public a: ClassA;
constructor(name: string, a: ClassA) {
this.name = name;
this.a = a;
}
}
@Entry @Entry
@Component @Component
...@@ -588,10 +608,10 @@ struct Parent { ...@@ -588,10 +608,10 @@ struct Parent {
build() { build() {
Column() { Column() {
Button('change') Button('change')
.onClick(() => { .onClick(() => {
this.votes.name = "aaaaa" this.votes.name = "aaaaa"
this.votes.a.title = "wwwww" this.votes.a.title = "wwwww"
}) })
Child({ vote: this.votes }) Child({ vote: this.votes })
} }
...@@ -600,33 +620,33 @@ struct Parent { ...@@ -600,33 +620,33 @@ struct Parent {
@Component @Component
struct Child { struct Child {
@Prop vote: ClassB @Prop vote: ClassB = new ClassB('', new ClassA(''));
build() { build() {
Column() { Column() {
Text(this.vote.name).fontSize(36).fontColor(Color.Red).margin(50) Text(this.vote.name).fontSize(36).fontColor(Color.Red).margin(50)
.onClick(() => { .onClick(() => {
this.vote.name = 'Bye' this.vote.name = 'Bye'
}) })
Text(this.vote.a.title).fontSize(36).fontColor(Color.Blue) Text(this.vote.a.title).fontSize(36).fontColor(Color.Blue)
.onClick(() => { .onClick(() => {
this.vote.a.title = "openHarmony" this.vote.a.title = "openHarmony"
}) })
Child1({vote1:this.vote.a}) Child1({vote1:this.vote.a})
} }
} }
} }
@Component @Component
struct Child1 { struct Child1 {
@Prop vote1: ClassA @Prop vote1: ClassA = new ClassA('');
build() { build() {
Column() { Column() {
Text(this.vote1.title).fontSize(36).fontColor(Color.Red).margin(50) Text(this.vote1.title).fontSize(36).fontColor(Color.Red).margin(50)
.onClick(() => { .onClick(() => {
this.vote1.title = 'Bye Bye' this.vote1.title = 'Bye Bye'
}) })
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册