当前位置:网站首页>HarmonyOS第二次培训笔记
HarmonyOS第二次培训笔记
2022-07-17 05:03:00 【m0_61169431】
目录
一、自定义组件
创建
JS UI框架支持自定义组件,用户可根据业务需求将已有的组件进行扩展,增加自定义的私有属性和事件,封装成新的组件,方便在工程中多次调用,提高页面布局代码的可读性。
- 定义一个专门存放自定义组件的文件夹 components.tabbar 并设置3个基础文件 tabbar.hml、tabbar.js、tabbar.css,需要注意的是:3个文件的文件名必须保持一致,不然会存在找不到文件的情况。该自定义组件的目的是给页面底部配置一个 tabbar 选项卡体验。
- 设置底部选项卡对应的 json 数据源,用来保存 icon 图片、标题,以及点击选中后的 icon 图片。
- 在common下创建一个文件夹来存放数据,并在js下把这组数据导入。

调用
name 属性指自定义组件名称(非必填),组件名称对大小写不敏感,默认使用小写,src 属性指自定义组件hml 文件路径(必填),若没有设置 name 属性,则默认使用 hml 文件名作为组件名。
事件绑定:自定义组件中绑定子组件事件使用 (on|@)child1 语法,子组件中通过 this.$emit('child1', { params: '传递参数' }) 触发事件并进行传值,父组件执行 bindParentVmMethod 方法并接收子组件传递的参数。
二、页面跳转
1.导入
import router from '@system.router';
2.绑定对应的事件,并且使用router.push

边栏推荐
- 银行联行号cnasp&查询(二)
- Learn about the configuration center
- Mysql8.026-- view (bottom)
- Learn about scheduled tasks in one article
- 2022 latest version of campus errand applet source code
- 畢設:基於Vue+Socket+Redis的分布式高並發防疫健康管理系統
- Attendance check-in and leave system based on SSM framework
- 解决[email protected]: `node install.js` 的问题
- 高等数学笔记:伍月习题选集
- Basic operations of index library operation
猜你喜欢
随机推荐
RestClient操作文档
Tidb performance optimization overview
Some concepts of ES
Warriors of the Visual Studio, Assemble! (warriors of visual studio, assemble!) Original 19:40:00 on July 12, 2009 label: compilation /mic
CVE-2021-44228 Log4j 复现及原理
一文了解配置中心
安装MySQL
solve [email protected] : `node install. Problems of js`
浅聊全局过滤器
【Batch】批量删除中间文件夹-个人研究脚本
三种高并发方式实现i++
Load balancer ribbon practice
mysql主从架构和读写分离、以及高可用架构
swagger的坑
The difference between junit4 and junit5
Overview of CKS core knowledge points
CVE-2020-10199 Nexus Repository Manager3远程命令执行漏洞复现
Yiwen takes you to know about haproxy
DSL搜索结果处理,包括排序,分页,高亮
ES文档操作








