[{"author":"同感","content":"同感","time":"2024-12-21 20:20:43"},{"author":"新手","content":"感谢分享,希望能看到更多这样的分享,为博主的互联网分享精神点赞,帮助我们这些新手摸清了坎坷,以下为官方API解释,可能因为博主的反馈Ark已经修复了示例:\n\ntext:\t\n设置输入框当前的文本内容。\n\n建议通过onChange事件将状态变量与文本实时绑定，\n\n避免组件刷新时TextInput中的文本内容异常。\n\n从API version 10开始，该参数支持$$双向绑定变量。\n\n以下为官方解释:\n\n$$运算符为系统内置组件提供TS变量的引用，使得TS变量和系统内置组件的内部状态保持同步。\n\n内部状态具体指什么取决于组件。例如，TextInput组件的text参数。\n\n说明\n$$还用于@Builder装饰器的按引用传递参数，开发者需要注意两种用法的区别。\n$$绑定的变量变化时，会触发UI的同步刷新。\nhttps://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-two-way-sync-V5#使用示例\n// xxx.ets\n@Entry\n@Component\nstruct TextInputExample {\n  @State text: string = ''\n  controller: TextInputController = new TextInputController()\n\n  build() {\n    Column({ space: 20 }) {\n      Text(this.text)\n      TextInput({ text: $$this.text, placeholder: 'input your word...', controller: this.controller })\n        .placeholderColor(Color.Grey)\n        .placeholderFont({ size: 14, weight: 400 })\n        .caretColor(Color.Blue)\n        .width(300)\n    }.width('100%').height('100%').justifyContent(FlexAlign.Center)\n  }\n}\n","time":"2025-09-01 14:13:28"}]
