@State curGridIndex: number = 0
@Builder
GridStyle(){
Stack(){
CrossGrid().visibility(this.curGridIndex === 1 ? Visibility.Visible : Visibility.None)
DiagonalGrid().visibility(this.curGridIndex === 2 ? Visibility.Visible : Visibility.None)
NineGrid().visibility(this.curGridIndex === 3 ? Visibility.Visible : Visibility.None)
}
.width(CommonConstants.FULL_SIZE)
.height(CommonConstants.FULL_SIZE)
}
Row{
//....
}.background(this.GridStyle())
当去改变状态量curGridIndex时,Builder内的UI并不会刷新。
参考示例代码: