然后我们在layout布局下新建一个xml布局文件:my_layout.xml
<?xml version="1.0" encoding="utf-8"?><DirectionalLayoutxmlns:ohos="http://schemas.huawei.com/res/ohos"ohos:height="match_parent"ohos:width="match_parent"ohos:background_element="#33AA0000"ohos:orientation="vertical"><Textohos:height="match_parent"ohos:width="match_parent"ohos:text="新的入口"ohos:text_size="30fp"ohos:text_alignment="center"/></DirectionalLayout>这里我们复制到media里一个小图标t4.png:

文章插图
最后,我们要在config.json中设置:
{"app": {"bundleName": "com.example.hanrupageability","vendor": "example","version": {"code": 1000000,"name": "1.0.0"}},"deviceConfig": {},"module": {"package": "com.example.hanrupageability","name": ".MyApplication","mainAbility": "com.example.hanrupageability.MainAbility","deviceType": ["phone"],"distro": {"deliveryWithInstall": true,"moduleName": "entry","moduleType": "entry","installationFree": false},"abilities": [{"skills": [{"entities": ["entity.system.home"],"actions": ["action.system.home"]}],"orientation": "unspecified","name": "com.example.hanrupageability.MyAbility","icon": "$media:t4","label": "$string:entry_MainAbility","type": "page","launchType": "standard"},{"orientation": "unspecified","name": "com.example.hanrupageability.MainAbility","icon": "$media:icon","description": "$string:mainability_description","label": "$string:entry_MainAbility","type": "page","launchType": "standard"}]}}然后启动项目,这个APP部署:
文章插图
点进去,就有了新的入口:

文章插图
我们也可以通过DevEco-Studio直接新建Ability,这样随着Ability的创建,会自动创建该Ability对应的AbilitySlice以及该AbilitSlice要加载的xml布局文件:

文章插图
然后填入Ability的信息:

文章插图
还有还有,会自动的配置config.json文件,超爽的:

文章插图
【PageAbility基本概念】
推荐阅读
- 6种事件驱动的架构模式
- 技术人员如何做晋升答辩
- redis实现分布式锁天然的缺陷
- Spring Boot 集成 MyBatis
- 杜甫被后人称为什么居士,春望的作者杜甫被后人称为什么
- JavaScript 中的“提升”是怎么回事?
- 详解Java反序列化漏洞
- 前端如何解决跨域问题?
- 负载均衡 LVS 与 Nginx 对比
- 我写代码时的小倔强
