当前位置:网站首页>鸿蒙第四次学习
鸿蒙第四次学习
2022-07-02 17:08:00 【菜鸟不是】
1.tabs
2.list
3.自定义组件
自定义组件是用户根据业务需求,将已有的组件组合,封装成的新组件,可以在工程中多次调用,从而提高代码的可读性。自定义组件通过element引入到宿主页面,使用方法如下 :
<element name='comp' src='../../common/component/comp.hml'></element>
<div>
<comp prop1='xxxx' @child1="bindParentVmMethod"></comp>
</div>
结合if-else使用自定义组件的示例:
<element name='comp1' src='../../common/component/comp1/comp1.hml'></element>
<element name='comp2' src='../../common/component/comp2/comp2.hml'></element>
<div>
<comp1 if="{
{showComp1}}" prop1='xxxx' @child1="bindParentVmMethodOne"></comp1>
<comp2 else prop1='xxxx' @child1="bindParentVmMethodTwo"></comp2>
</div>
- name属性指自定义组件名称(非必填),组件名称对大小写不敏感,默认使用小写。src属性指自定义组件hml文件路径(必填),若没有设置name属性,则默认使用hml文件名作为组件名。
- 事件绑定:自定义组件中绑定子组件事件使用(on|@)child1语法,子组件中通过this.$emit('child1', { params: '传递参数' })触发事件并进行传值,父组件执行bindParentVmMethod方法并接收子组件传递的参数。
边栏推荐
- What is cloud primordial? This time, I can finally understand!
- QQmlApplicationEngine
- Leetcode interview question 16.17 Continuous sequence
- 【Oracle 期末复习】表空间、表、约束、索引、视图的增删改
- Simulateur nightGod + application de test de capture de paquets Fiddler
- Wechat applet video sharing platform system graduation design completion (8) graduation design thesis template
- 什么是云原生?这回终于能搞明白了!
- ESP32-C3入门教程 问题篇⑪——esp-tls: create_ssl_handle failed, tls_io_instance->options.trusted_certs null
- After 22 years in office, the father of PowerShell will leave Microsoft: he was demoted by Microsoft for developing PowerShell
- Wechat applet video sharing platform system graduation design (3) background function
猜你喜欢
Web版3D可视化工具,程序员应该知道的97件事,AI前沿论文 | 资讯日报 #2022.07.01
Simulateur nightGod + application de test de capture de paquets Fiddler
Redis(6)----对象与数据结构
Leetcode 面试题 17.01. 不用加号的加法
Troubleshooting ideas that can solve 80% of faults
Leetcode 面试题 17.04. 消失的数字
RDK simulation experiment
微信小程序视频分享平台系统毕业设计毕设(4)开题报告
微信小程序视频分享平台系统毕业设计毕设(1)开发概要
A good programmer is worth five ordinary programmers!
随机推荐
初夏,开源魔改一个带击杀音效的电蚊拍!
Wechat applet video sharing platform system graduation design completion (1) development outline
Web chat tool
夜神模拟器+Fiddler抓包测试App
快速排序基本思路(通俗易懂+例子)「建议收藏」
Uncover the whole link communication process of dewu customer service im
MySQL 关于 only_full_group_by 限制
昨天阿里学长写了一个责任链模式,竟然出现了无数个bug
Leetcode 面试题 16.17. 连续数列
【西北工业大学】考研初试复试资料分享
Wechat nucleic acid detection and appointment applet system graduation design (3) background function
Chain game system development (unity3d chain game development details) - chain game development mature technology source code
C语言中函数参数传递的三种方式
How to write controller layer code gracefully?
深度神经网络总结
Wechat nucleic acid detection appointment applet system graduation design completion (1) development outline
Is Guojin securities a state-owned enterprise? Is it safe to open an account in Guojin securities?
Leetcode 面试题 17.04. 消失的数字
Typical application of "stack" - expression evaluation (implemented in C language)
paddlepaddle 28 搭建基于卷积的自动编码机