提交 1599fe90 编写于 作者: E ester.zhou

update doc (8462)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 136cee94
...@@ -11,7 +11,7 @@ Table 1 @Provide ...@@ -11,7 +11,7 @@ Table 1 @Provide
| Decorator parameter | A constant of the string type, which is used to set an alias for a decorated variable. If an alias is specified, implement the data update for this alias. If there is no alias, use the variable name as the alias. @Provide("_alias_") is recommended. | | Decorator parameter | A constant of the string type, which is used to set an alias for a decorated variable. If an alias is specified, implement the data update for this alias. If there is no alias, use the variable name as the alias. @Provide("_alias_") is recommended. |
| Synchronization mechanism | The @Provide decorated variable is similar to the @state variable. You can modify the variable to re-render the page. You can also modify the @Consume decorated variable to modify the @State decorated variable reversely. | | Synchronization mechanism | The @Provide decorated variable is similar to the @state variable. You can modify the variable to re-render the page. You can also modify the @Consume decorated variable to modify the @State decorated variable reversely. |
| Initial value | The initial value must be set. | | Initial value | The initial value must be set. |
| Page re-rendering scenarios | The following will trigger page re-rendering:<br/>- Changes of variables in primitive types (boolean, string, and number)<br/>- Changes of the @Observed decorated classes or their attributes<br/>- Adding, deleting, or updatingelements in an array | | Page re-rendering scenarios | The following will trigger page re-rendering:<br/>- Changes of variables in primitive types (boolean, string, and number)<br/>- Changes of the @Observed decorated classes or their attributes<br/>- Adding, deleting, or updating elements in an array |
Table 2 @Consume Table 2 @Consume
...@@ -34,44 +34,44 @@ The description of other attributes is the same as that of @Provide. ...@@ -34,44 +34,44 @@ The description of other attributes is the same as that of @Provide.
@Entry @Entry
@Component @Component
struct CompA { struct CompA {
@Provide("reviewVote") reviewVotes : number = 0; @Provide("reviewVote") reviewVotes : number = 0;
build() { build() {
Column() { Column() {
CompB() CompB()
Button() { Button() {
Text(`${this.reviewVotes}`) Text(`${this.reviewVotes}`)
.fontSize(30) .fontSize(30)
} }
.onClick(() => { .onClick(() => {
this.reviewVotes += 1; this.reviewVotes += 1;
}) })
}
} }
}
} }
@Component @Component
struct CompB { struct CompB {
build() { build() {
Column() { Column() {
CompC() CompC()
}
} }
}
} }
@Component @Component
struct CompC { struct CompC {
@Consume("reviewVote") reviewVotes : number; @Consume("reviewVote") reviewVotes : number;
build() { build() {
Column() { Column() {
Button() { Button() {
Text(`${this.reviewVotes}`) Text(`${this.reviewVotes}`)
.fontSize(30) .fontSize(30)
} }
.onClick(() => { .onClick(() => {
this.reviewVotes += 1; this.reviewVotes += 1;
}) })
}
} }
}
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册