问题描述
@State本身就可以使UI刷新,目前依然不明白$$的具体用途。
@Entry
@Component
struct bindPopupPage {
@State customPopup: boolean = false;
build() {
Column() {
Button('Popup').margin(20).onClick(() =\> {
this.customPopup = !this.customPopup
}).bindPopup(\$\$this.customPopup, { message: 'showPopup' })
}
}
}
解决措施
$$
是组件的提供的内置组件双向同步,
$$
运算符为系统内置组件提供TS变量的引用,使得TS变量和系统内置组件的内部状态保持同步。状态变量是js层到cpp层的变化,$$是cpp层到js层的变化。
参考链接
$$语法:内置组件双向同步