跳到主要内容

$$语法:系统组件双向同步

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

内部状态的具体含义取决于组件。例如,TextInput组件的text参数。

使用规则

使用示例

TextInput方法的text参数为例:

// xxx.ets
@Entry
@Component
struct TextInputExample {
@State text: string = '';
controller: TextInputController = new TextInputController();

build() {
Column({ space: 20 }) {
Text(this.text)
TextInput({ text: $$this.text, placeholder: 'input your word...', controller: this.controller })
.placeholderColor(Color.Grey)
.placeholderFont({ size: 14, weight: 400 })
.caretColor(Color.Blue)
.width(300)
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.Center)
}
}