一、創(chuàng)建項目
?
?
二、創(chuàng)建卡片
?
?
三、添加資源
?
四、具體代碼
@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
}
});
})
}
}
五、運行案例
?
?
六、案例卡片效果
?
文章來源:http://www.zghlxwxcb.cn/news/detail-627759.html
七、代碼地址
(HarmonyOSAPP開發(fā)相關組件: 深圳市蛟龍騰飛網絡科技有限公司 - Gitee.com)文章來源地址http://www.zghlxwxcb.cn/news/detail-627759.html
到了這里,關于HarmonyOS/OpenHarmony-ArkTS基于API9元服務開發(fā)快速入門的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!