一、创建项目
二、创建卡片
三、添加资源
四、具体代码
@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
}
});
})
}
}
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.
复制
五、运行案例
六、案例卡片效果
七、代码地址
(https://gitee.com/jltfcloudcn/jump_to/tree/master/MyApplication)