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)

相关推荐
大雷神14 分钟前
HarmonyOS智慧农业管理应用开发教程--高高种地--第27篇:考试系统 - 成绩分析与错题
华为·harmonyos
菜鸟小芯1 小时前
【开源鸿蒙跨平台开发先锋训练营】DAY8~DAY13 底部选项卡&我的页面功能实现
flutter·harmonyos
一起养小猫2 小时前
Flutter for OpenHarmony 进阶:表达式解析算法与计算器核心实现
算法·flutter·harmonyos
听麟3 小时前
HarmonyOS 6.0+ PC端系统级桌面插件开发实战:ArkUI Widget进阶与系统交互深度集成
华为·交互·harmonyos
不爱吃糖的程序媛3 小时前
Flutter 三方库鸿蒙(OHOS)适配分析流程
flutter·华为·harmonyos
2301_796512523 小时前
【精通篇】打造React Native鸿蒙跨平台开发高级复合组件库开发系列:Lazyload 懒加载(懒加载的图片)
前端·javascript·react native·react.js·ecmascript·harmonyos
mocoding3 小时前
我这样用鸿蒙化Flutter三方库file_selector实现单图片和多图片选择
flutter·华为·harmonyos
听麟3 小时前
HarmonyOS 6.0+ PC端视频剪辑工具开发实战:Media Kit进阶与硬件加速渲染落地
华为·harmonyos
浩宇软件开发3 小时前
基于OpenHarmony鸿蒙开发医院预约挂号系统(前端后端分离)
前端·华为·harmonyos
不爱吃糖的程序媛4 小时前
如何判断Flutter三方库是否需要OHOS适配开发?附完整适配指导
flutter·华为·harmonyos