ArkUI组件--Button组件

1.声明Button组件

复制代码
Button(label?:ResourceStr)
#label是按钮上显示的文本

①label是文字类型

所写文字会在按钮上显示

②不输入label内容,需要额外定义一些描述。例如插入图片(需要定义图片属性)

复制代码
Button(){
    Image($r('app.media.xxx'))
        .width(250)
        .height(20)
        ...
}

2.添加属性和事件信息

复制代码
Button("文本信息")
    .width(250)
    .height(30)
    .type(ButtonType.Normal)    #按钮类型,可选,特有属性
    .onClick(() =>{
    #定义点击事件
})

ButtonType的可选项及其应用场景

相关推荐
盐焗西兰花9 小时前
鸿蒙学习实战之路-ArkTS循环渲染_ForEach使用指南
学习·华为·harmonyos
俩毛豆12 小时前
【鸿蒙生态共建】意图框架的使用-通过小艺调起京东发起搜索《精通HarmonyOS NEXT :鸿蒙App开发入门与项目化实战》读者福利
华为·harmonyos·小艺
Devil枫15 小时前
HarmonyOS 应用草稿箱功能设计方案(安全可靠+轻量化存储)
华为·harmonyos
芒鸽21 小时前
windows上使用Lycium 交叉编译移植鸿蒙三方库指南
windows·华为·harmonyos
FrameNotWork1 天前
HarmonyOS 广告 SDK 封装实战:从原生 Ads Kit 到可复用广告组件
华为·harmonyos
木斯佳1 天前
[鸿蒙2025领航者闯关] 把养老院装进口袋:如何利用鸿蒙6新特性探索智慧医养场景
华为·harmonyos
wangxiaowu19861 天前
HarmonyOS NEXT和通用JSBridge
华为·harmonyos
l134062082352 天前
Flutter Geocoding 在鸿蒙上的使用指南
flutter·华为·harmonyos
俩毛豆2 天前
【毛豆工具集】【UI】【多设备适配】实现与屏幕密度等倍的图片加载
华为·harmonyos
l134062082352 天前
344.在鸿蒙上使用 animations Flutter 包的指南
flutter·华为·harmonyos