- In the parent component (Father), use @Local to bind the reviewVotes parameter.
@Entry
@ComponentV2
struct Father {
@Local reviewVotes: number = 0;
build() {
Column() {
Son({ reviewVotes: this.reviewVotes })
Button(`Father: ${this.reviewVotes}`)
}
}
} - In the child component (Son), use @Param to receive the reviewVotes parameter from the parent component.
@ComponentV2
struct Son {
@Require @Param reviewVotes: number = 1;
build() {
Column() {
Grandson({ reviewVotes: this.reviewVotes })
}
}
} - In the grandchild component (Grandson), use @Param to receive the reviewVotes parameter passed from the child component.
@ComponentV2
struct Grandson {
@Require @Param reviewVotes: number = 1;
build() {
Column() {
Button(`Grandson: ${this.reviewVotes}`)
}.width('100%')
}
}