当前位置:网站首页>HarmonyOS. two
HarmonyOS. two
2022-06-24 13:51:00 【Ci Xun】
(1). Creation of custom components
- Define a folder for storing custom components components.tabbar And set up 3 Base file tabbar.hml、tabbar.js、tabbar.css, It should be noted that :3 The file names of two files must be consistent , Otherwise, the file will not be found . The purpose of this custom component is to configure a... At the bottom of the page tabbar Tab experience .
- Set the corresponding settings for the bottom tab json data source , For preservation icon picture 、 title , And click the selected icon picture .

- Use toolbar + toolbar-item Built in components build the bottom tabbar Tab Services 「tabbar.hml」
- Import tabbarItem data , And set the corresponding data , At the same time, set the click event Click the corresponding button for dynamic setting icon Choose .
- Set up CSS style take tabbar Tab bottom 「tabbar.css」
(2) Call of custom component
name Property refers to the custom component name ( Not required ), Component names are case insensitive , The default is lowercase ,src Properties refer to custom components hml File path ( Required ), If not set name attribute , It is used by default hml Use the file name as the component name .
Event binding : Binding subcomponent events in custom components use (on|@)child1 grammar , Passed in the child component this.$emit('child1', { params: ' Pass parameters ' }) Trigger the event and transfer the value , Parent component execution bindParentVmMethod Method and receive the parameters passed by the subcomponent .
(3) Parent component passed slot Publish content to subcomponents
1. Ordinary slot Slot distribution
2. Named slot distribution 
(3) Implementation of routing function
Page definition :
stay Pages Create a new folder under the folder to represent the required route , Of course , We can also create a new one Ablity Experience , Here's a demonstration Pages.Name.
stay Under the new folder, be sure to create three new files
index.hml、index.js、index.cssThree files , The file name must use index To name it , Using other names will result in file dependencies not being found .Shortcut , You can select the corresponding Ability Pages Under the folder , then new page Add page directly , And will automatically register the route , This is more convenient
stay config.json In file

Use of routes :
1. Import routing module
2.router.push(OBJECT), Jump to the specified page in the application .
3.router.replace(OBJECT), Replace the current page with a page in the application , And destroy the replaced page .
4.router.back(OBJECT), Return to the previous page or the specified page .
5.router.clear(), Clear all history pages in the page stack , Only keep the current page as the top page of the stack .
6.router.getLength(), Get the number of pages currently in the page stack .
7.router.getState(), Get the status information of the current page .
边栏推荐
- 2022年质量员-设备方向-岗位技能(质量员)复训题库及在线模拟考试
- Kotlin interface generic covariant inversion
- kotlin 协程上下文和调度器
- How does webrtc obtain video stream data on the C ++ side?
- Explain the difference between iaas/paas/saas by cooking rice
- The first open source MySQL HTAP database in China will be released soon, and the three highlights will be notified in advance
- 【R语言数据科学】(十四):随机变量和基本统计量
- 常识知识点
- **Unity中莫名其妙得小问题-灯光和天空盒
- Usage of multimeter
猜你喜欢

这几个默认路由、静态路由的配置部署都不会,还算什么网工!

npm包【详解】(内含npm包的开发、发布、安装、更新、搜索、卸载、查看、版本号更新规则、package.json详解等)

吉时利静电计宽测量范围

如何在物联网低代码平台中进行任务管理?

Huawei PC grows against the trend, and product power determines everything

Vulnerability management mistakes that CIOs still make

万用表测量电阻图解及使用注意事项

Daily question 8-515 Find the maximum value in each tree row

Developer survey: rust/postgresql is the most popular, and PHP salary is low

黄金年代入场券之《Web3.0安全手册》
随机推荐
杰理之开了多种解码格式插卡到播放等待的时间长【篇】
How does webrtc obtain video stream data on the C ++ side?
redis 数据类型详解
杰理之TIMER0 用默认的 PA13 来检测脉宽【篇】
常识知识点
The second phase of freshman engineering education seminar is to enroll in the China 100 school peer program
【R语言数据科学】(十四):随机变量和基本统计量
Usage of multimeter
PM should also learn to reflect every day
2022 coal mine gas drainage operation certificate examination questions and simulation examination
10 个 Reduce 常用“奇技淫巧”
每日一题day8-515. 在每个树行中找最大值
金鱼哥RHCA回忆录:DO447管理项目和开展作业--为ansible剧本创建一个项目
Goldfish rhca memoirs: do447 managing projects and conducting operations -- creating a project for ansible scripts
[one picture series] one picture to understand Tencent Qianfan apaas
2022年江西省安全员B证考试题库模拟考试平台操作
龙蜥开发者说:首次触电,原来你是这样的龙蜥社区? | 第 8 期
Prometheus pushgateway
Memory introduction
知识经济时代,教会你做好知识管理