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的可选项及其应用场景

相关推荐
Math_teacher_fan1 天前
Flutter 跨平台开发实战:鸿蒙与音乐律动艺术(六)、Lissajous 利萨茹曲线:频率耦合的轨迹艺术
flutter·ui·数学建模·华为·harmonyos·鸿蒙系统
xmdy58661 天前
Flutter+开源鸿蒙实战|智安盾电商溯源平台Day3 溯源查询逻辑+鸿蒙网络请求适配
flutter·开源·harmonyos
maaath1 天前
【maaath】Flutter 跨平台日历日程应用开发实战
flutter·华为·harmonyos
LeesonWong1 天前
架构困境与四层结构化设计
harmonyos
梦想不只是梦与想1 天前
鸿蒙 应用市场更新功能:版本检测与更新提醒
harmonyos·鸿蒙·版本更新
xmdy58661 天前
Flutter+开源鸿蒙实战|智安盾电商溯源平台Day2 首页+核心入口UI开发(鸿蒙多端适配)
flutter·开源·harmonyos
nashane2 天前
HarmonyOS 6学习:HAR包与HSP包的选择与优化指南
学习·华为·harmonyos·harmonyos 5
全栈若城2 天前
自定义 TabBar 实战:浮动标签栏与舵式标签栏
harmonyos·harmonyos6·三方库开发
maaath2 天前
【maaath】Flutter for OpenHarmony 学习答题应用实战开发
学习·flutter·华为·harmonyos
李游Leo2 天前
别再拼 JSON 了:HarmonyOS UDMF 跨应用数据流转实践
harmonyos