Arkui-组件

作者:犯困乐 发布时间: 2026-03-17 阅读量:21 评论数:0

什么是组件

组件独立的代码块,具有特定功能样式,并且可以在页面中独立使用重复使用ArkUI为开发者提供了可以直接在程序中使用的组件,通过组件可以快速构建UI,提高UI的开发效率一致性

组件的基本使用方法

下面列举一些AkU中常用的通用属性通用事件

ok按钮

按钮部分:

Button('ok')
        .onClick(() => {
          this.message='你点击了ok按钮'
          console.log('点击了ok按钮');
        })
        .width('80%')
        .height(48)
        .borderRadius(10)
        .fontSize(16)
        .alignRules({
          bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
          middle: { anchor: '__container__', align: HorizontalAlign.Center }
        })
        .margin({ bottom: 50 })

评论