当前位置: 首页 > news >正文

鸿蒙Next 支持数据双向绑定的组件:Checkbox--Search--TextInput

Checkbox

$$语法,$$绑定的变量发生变化时,会触发UI的刷新

@Entry
@Component
struct MvvmCase {
@State
isMarry:boolean = false@StatesearchText:string = ''build() {Grid(){GridItem(){Column(){Text("checkbox 的双向绑定")Checkbox().select($$this.isMarry)Text(this.isMarry+"")Button('改变').onClick(()=>{this.isMarry=!this.isMarry})}}.height(200).backgroundColor(Color.Yellow)}.width('100%').height('100%').columnsTemplate("1fr 1fr").columnsGap(20).rowsGap(20)}
}

Search

@Entry
@Component
struct MvvmCase {
@State
isMarry:boolean = false@StatesearchText:string = ''build() {Grid(){GridItem(){Column(){Text("search 的双向绑定")Search({value:$$this.searchText})Text(this.searchText+"")Button('改变').onClick(()=>{this.searchText='老宋你好'})}}.height(200).backgroundColor(Color.Pink)}.width('100%').height('100%').columnsTemplate("1fr 1fr").columnsGap(20).rowsGap(20)}
}

​​​​​​​ 

TextInput

@Entry
@Component
struct MvvmCase {
@State
isMarry:boolean = false@StatesearchText:string = ''controller: TextInputController = new TextInputController()build() {Grid(){GridItem(){Column(){Text("TextInput 的双向绑定")TextInput({ text: $$this.searchText, placeholder: 'TextInput 的双向绑定', controller: this.controller })Text(this.searchText+"")Button('改变').onClick(()=>{this.searchText='老宋你好01'})}}.height(200).backgroundColor(Color.Pink)}.width('100%').height('100%').columnsTemplate("1fr 1fr").columnsGap(20).rowsGap(20)}
}

还有很多组件都支持双向绑定

http://www.lryc.cn/news/322179.html

相关文章:

  • 跨越时空的纽带:探索Facebook如何连接人与人
  • LabVIEW湍流等离子体束热效率优化
  • 21个 JVM 技术点详解(附面试解答)
  • mysql逗号分隔字段拆成行简述
  • 最新梨花带雨网页音乐播放器二开优化修复美化版全开源版本源码下载
  • golang 操作redis
  • macOS - 获取硬件设备信息
  • 突破编程_C++_STL教程( queue 的基础知识)
  • Hystrix 容错机制数据监控可视界面无法加载
  • 【Java】POI解析excel
  • AI浸入社交领域,泛娱乐APP如何抓住新风口?
  • 遥感图像地物分类流程
  • JS13-事件的绑定和事件对象Event
  • pycorrector检测OCR错字实践
  • RDD算子介绍(三)
  • Redis的脑裂问题
  • 【算法】雪花算法生成分布式 ID
  • FFplay使用滤镜添加字幕到现有视频显示
  • 【Python + Django】Django模板语法 + 请求和响应
  • 大数据面试总结 四
  • Spring Boot: 使用MongoOperations操作mongodb
  • PyTorch 深度学习(GPT 重译)(六)
  • MyBatis3源码深度解析(十七)MyBatis缓存(一)一级缓存和二级缓存的实现原理
  • Go --- Go语言垃圾处理
  • 力扣每日一题30:串联所有单词的子串
  • vim | vim的快捷命令行
  • 项目管理平台-01-BugClose 入门介绍
  • web集群-lvs-DR模式基本配置
  • 基于深度学习的面部情绪识别算法仿真与分析
  • C语言经典面试题目(十六)