1 Star 0 Fork 5.4K

ohos / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
arkts-two-way-sync.md 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
zengyawen 提交于 2023-04-10 15:36 . update docs

$语法:内置组件双向同步

$$运算符为系统内置组件提供TS变量的引用,使得TS变量和系统内置组件的内部状态保持同步。

内部状态具体指什么取决于组件。例如,bindPopup属性方法的show参数。

使用规则

  • 当前$$支持基础类型变量,以及@State、@Link和@Prop装饰的变量。

  • 当前$$仅支持bindPopup属性方法的show参数,Radio组件的checked属性,Refresh组件的refreshing参数。

  • $$绑定的变量变化时,会触发UI的同步刷新。

使用示例

bindPopup属性方法的show参数为例:

// xxx.ets
@Entry
@Component
struct bindPopupPage {
  @State customPopup: boolean = false;

  build() {
    Column() {
      Button('Popup')
        .margin(20)
        .onClick(() => {
          this.customPopup = !this.customPopup
        })
        .bindPopup($$this.customPopup, {
          message: 'showPopup'
        })
    }
  }
}

popup

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yeyinglong/docs.git
git@gitee.com:yeyinglong/docs.git
yeyinglong
docs
docs
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891