HarmonyOS/OpenHarmony-ArkTS基于API9元服务开发快速入门

一、创建项目

二、创建卡片

三、添加资源

四、具体代码

复制代码
@Entry
@Component
struct WidgetNewCard {
  /*
   * The title.
   */
  readonly TITLE: string = 'harmonyOs';
  readonly CONTEXT: string = '技术构建万物智联';

  /*
   * The action type.
   */
  readonly ACTION_TYPE: string = 'router';

  /*
   * The ability name.
   */
  readonly ABILITY_NAME: string = 'EntryAbility';

  /*
   * The message.
   */
  readonly MESSAGE: string = 'add detail';

  /*
   * The with percentage setting.
   */
  readonly FULL_WIDTH_PERCENT: string = '100%';

  /*
   * The height percentage setting.
   */
  readonly FULL_HEIGHT_PERCENT: string = '100%';

  build() {
    Row() {
      Column() {
        Text(this.TITLE)
          .fontSize(14)
          .fontColor(0xFEFEFE)
          .fontWeight(600)
        Text(this.CONTEXT)
          .fontSize(14)
          .fontColor(0xFEFEFE)
          .fontWeight(600)
      }
      .width(this.FULL_WIDTH_PERCENT)
    }
    .backgroundImage($r("app.media.new_bg"))
    .backgroundImageSize(ImageSize.Cover)
    .height(this.FULL_HEIGHT_PERCENT)
    .onClick(() => {
      postCardAction(this, {
        "action": this.ACTION_TYPE,
        "abilityName": this.ABILITY_NAME,
        "params": {
          "message": this.MESSAGE
        }
      });
    })
  }
}

五、运行案例

六、案例卡片效果

七、代码地址

(HarmonyOSAPP开发相关组件: 深圳市蛟龙腾飞网络科技有限公司 - Gitee.com)

相关推荐
u***j3241 小时前
HarmonyOS在智能家居中的实践
华为·智能家居·harmonyos
柒儿吖12 小时前
Electron for 鸿蒙PC 窗口问题完整解决方案
javascript·electron·harmonyos
xiaocao_102313 小时前
鸿蒙手机上有哪些比较好用的记事提醒工具?
华为·智能手机·harmonyos
坚果派·白晓明14 小时前
开源鸿蒙终端工具Termony构建HNP包指导手册Mac版
macos·开源·harmonyos
ChinaDragon16 小时前
HarmonyOS:属性动画
harmonyos
坚果派·白晓明16 小时前
开源鸿蒙终端工具Termony增加外部HNP包合入base.hnp的设计与实现实战教程
华为·开源·harmonyos
HarmonyOS_SDK16 小时前
性能优化 | HarmonyOS预加载,三步即可提升APP页面的响应速度
harmonyos
坚果派·白晓明16 小时前
开源鸿蒙终端工具Termony环境配置指导手册Mac版
开源·harmonyos·项目实战
啃火龙果的兔子16 小时前
Kotlin 修改安装到桌面后的应用图标
开发语言·kotlin·harmonyos
白茶三许21 小时前
关于Flutter版本过低导致鸿蒙虚拟机启动失败的问题解决
flutter·开源·harmonyos·openharmony