当前位置:网站首页>华为鸿蒙开发第三课
华为鸿蒙开发第三课
2022-06-21 19:54:00 【不想秃头的学生】
学习网站:千锋教育鸿蒙系统开发教程,HarmonyOS 2.0鸿蒙应用开发实战教程(开发属于自己的第一个鸿蒙APP)_哔哩哔哩_bilibili
官方文档:HarmonyOS系统开发指导_HarmonyOS系统能力API参考 - HarmonyOS应用开发官网
一、目录结构

- java目录:仅Phone、Tablet、TV和Wearable设备的JS工程才存在,作为HarmonyOS应用/服务的启动入口。
- common目录:用于存放公共资源文件,如媒体资源、自定义组件和JS文档等。
- i18n目录:用于存放多语言的json文件,可以在该目录下定义应用/服务在不同语言系统下显示的内容,如应用/服务文本词条、图片路径等,详情请参考多语言支持。
- pages目录:pages文件夹下可以包含1个或多个页面,每个页面都需要创建一个文件夹。页面文件夹下主要包含3种文件类型:css、js和hml文件。
- pages>index>index.hml文件:hml文件定义了页面的布局结构,使用到的组件,以及这些组件的层级关系,详情请参考HML语法参考。
- pages>index>index.css文件:css文件定义了页面的样式与布局,包含样式选择器和各种样式属性等,详情请参考CSS语法参考。
- pages>index>index.js文件:js文件描述了页面的行为逻辑,此文件里定义了页面里所用到的所有的逻辑关系,比如数据、事件等,详情请参考JS语法参考。
- resources:用于存放资源配置文件,比如:全局样式、多分辨率加载等配置文件。resources资源引用示例请参考根据设备分辨率加载图片。
- app.js文件:全局的JavaScript逻辑文件和应用/服务的生命周期管理。
二、生命周期

- onStart()
当系统首次创建 Page 实例时,触发该回调。对于一个 Page 实例,该回调在其生命周期过程中仅触发一次, Page 在该逻辑后将进入 INACTIVE 状态。开发者必须重写该方法,并在此配置默认展示的 AbilitySlice。
- onActive()
Page 会在进入 INACTIVE 状态后来到前台,然后系统调用此回调。Page 在此之后进入 ACTIVE 状态,该状态是应用与用户交互的状态。Page 将保持在此状态,除非某类事件发生导致 Page 失去焦点,比如用户点击返回键或导航到其他 Page。当此类事件发生时,会触发 Page 回到 INACTIVE 状态,系统将调用 onInactive() 回调。此后,Page 可能重新回到 ACTIVE 状态,系统将再次调用 onActive() 回调。因此,开发者通常需要成对实现 onActive()和 onInactive(),并在 onActive() 中获取在 onInactive() 中被释放的资源。
- onStop()
系统将要销毁 Page 时,将会触发此回调函数,通知用户进行系统资源的释放。
三、list组件
list-容器组件-组件-基于JS扩展的类Web开发范式-手机、平板、智慧屏和智能穿戴开发-JS API参考-HarmonyOS应用开发
https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-components-container-list-0000000000611496
<list class="list">
<list-item for="{
{ array }}" class="listItem">
<text class="text">{
{ $item.value }}</text>
</list-item>
</list>
data: {
title: "",
test:"测试",
mid:'',
"array": [
{
"value": "列表文本"
},
{
"value": "列表文本"
},
{
"value": "列表文本"
},
{
"value": "列表文本"
},
],
},
边栏推荐
- 杰理之做蓝牙发射的时候,回链没有声音解决方法【篇】
- 撰写学术论文引用文献时,标准的格式是怎样的?
- 数据库管理:Navicat Premium 15
- 请问一下,大学生查文献在哪个网站比较好呀?
- Go单元测试对数据库CRUD进行Mock测试
- 测评 | 在生活中,你是一位什么样的人呢?
- Time modification method for search device of Jerry's Bluetooth transmitter [chapter]
- Jerry's acquisition of current audio file (long) file name and current (long) folder name [chapter]
- JS object operation (much simpler than C object)
- Maximum weight matching of bipartite graph (build a board and stick to two questions)
猜你喜欢

天齐锂业通过聆讯:单季净利33亿 蒋卫平夫妇身价超500亿

ACM. HJ61 放苹果 ●

杰理之蓝牙发射器的搜索设备的时间修改方法【篇】
![There is no sound solution to the loopback when jerryzhi launches Bluetooth [chapter]](/img/ba/377ec19ca22c2c106f227e864f1e9e.png)
There is no sound solution to the loopback when jerryzhi launches Bluetooth [chapter]

PowerPoint tutorial, how to organize slides into groups in PowerPoint?

Yanyu saltalk obtained USD 8million round a financing: continue to expand team and market coverage

Definition of unused processing methods when compiling C51 with keil 5

Summary of intelligence problems

ctfshow 105-127

智力题整理总结
随机推荐
Trend media Hypebeast plans to be listed on the curve: with a price of USD 530million, it is planned to be completed in the third quarter
数据库管理:Navicat Premium 15
What websites or software are available to translate English literature into Chinese?
Jerizhi, processing method for prompting chip information mismatch and error code 10 [chapter]
Uibutton implements left text and right picture
Operation of 2022 welder (Advanced) examination question bank simulation examination platform
微信小程序js把数字转化成字母
免费又好用的参考文献管理软件zotero该怎么使用?可以同时支持中文和英文吗?...
ACM. Hj61 put apple ●
J - Count the string HDU - 3336 (KMP)
盐语Saltalk获800万美元A轮融资:继续扩大团队及市场覆盖
Jerry's acquisition of current audio file (long) file name and current (long) folder name [chapter]
科研漫画 | 看图可以学脑电,来试试?
ARP protocol and ARP attack
How to orderly coordinate and manage multiple R & D projects?
ACM. HJ51 输出单向链表中倒数第k个结点 ●
tkinter绘制组件(29)——单选组控件
JS里的数据类型(基础)
Definition of unused processing methods when compiling C51 with keil 5
With what to save you? My attention