扫一扫,分享给好友
一、事件 组件区域变化事件指组件显示的尺寸、位置等发生变化时触发的事件。(api8开始支持)
二、示例
代码:
@Entry @Component struct AreaExample { @State value: string = 'Text' @State sizeValue: string = '' build() { Column() { Text(this.value) .backgroundColor(Color.Gray).margin(30).fontSize(20).padding(4) .onClick(() => { this.value = this.value + ' | Text' }) .onAreaChange((oldValue: Area, newValue: Area) => { console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} value is ${JSON.stringify(newValue)}`) this.sizeValue = JSON.stringify(newValue) }) Text('new area is: \n' + this.sizeValue).margin({ right: 30, left: 30 }) } .width('100%').height('100%').margin({ top: 30 }) } }
网站代码地址:https://gitee.com/jltfcloudcn/jump_to/tree/master/AreaChange
发布
HarmonyOS华为鸿蒙系统HarmonyOS操作系统OpenHarmonyRTOS同欣智能科技移植系统架构全场景分布式原子化服务鸿蒙操作系统微内核鸿蒙3.0
HarmonyOS/OpenHarmony原生应用-ArkTS万能卡片组件Badge
HarmonyOS线性容器特性及使用场景
OpenHarmony应用模型的构成要素与Stage优势
OpenHarmony应用开发涉及的主要因素与UX设计规范
HarmonyOS如何使用异步并发能力进行开发
OpenHarmony应用核心技术理念与需求机遇简析
OpenHarmony应用分发运营体系
HarmonyOS创作激励计划启动:助力技术创作突破边界
Harmony自定义页面请求与前端页面调试
OpenHarmony应用程序包整体说明
电子发烧友网
电子发烧友论坛