当前位置:网站首页>鸿蒙第四次学习
鸿蒙第四次学习
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方法并接收子组件传递的参数。

边栏推荐
- How to use PS to extract image color and analyze color matching
- QQmlApplicationEngine
- 夜神模拟器+Fiddler抓包测试App
- 微信小程序视频分享平台系统毕业设计毕设(3)后台功能
- 微信小程序视频分享平台系统毕业设计毕设(1)开发概要
- SteamOS 3.3 Beta 发布,Steam Deck 中文键盘终于来了
- Ue4 dessine un cercle avec une ligne de contour
- 【西北工业大学】考研初试复试资料分享
- Web实时通信技术之Websocket
- Is it safe to buy funds on Alipay account
猜你喜欢

A good programmer is worth five ordinary programmers!

呆错图床系统源码图片CDN加速与破J防盗链功能

UE4 draw a circle with spline

微信小程序视频分享平台系统毕业设计毕设(4)开题报告

Implementation shadow introduction

如何清理废弃pv和其对应的文件夹

Leetcode 面试题 16.15. 珠玑妙算

UE4 用spline画正圆
![[Yugong series] July 2022 go teaching course 001 introduction to go language premise](/img/f2/3b95f53d67cd1d1979163910dbeeb8.png)
[Yugong series] July 2022 go teaching course 001 introduction to go language premise

任职 22 年,PowerShell 之父将从微软离职:曾因开发 PowerShell 被微软降级过
随机推荐
AI开发调试系列第二弹:多机分布式调测探索之旅
Unity learning shader notes [82] black and white processing of enhanced single channel color rendering
How to use PS to extract image color and analyze color matching
初夏,开源魔改一个带击杀音效的电蚊拍!
Wechat applet video sharing platform system graduation design completion (6) opening defense ppt
Use dosbox to run the assembly super detailed step "suggestions collection"
QQmlApplicationEngine
Redis(6)----对象与数据结构
719. Find the distance of the number pair with the smallest K
Summary of fun free GM games
快速排序基本思路(通俗易懂+例子)「建议收藏」
Wechat nucleic acid detection and appointment applet system graduation design (3) background function
What is cloud primordial? This time, I can finally understand!
How to set vscode to delete the whole line shortcut key?
exness深度好文:动性系列-黄金流动性实例分析(五)
链游系统开发(Unity3D链游开发详情)丨链游开发成熟技术源码
300+篇文献!一文详解基于Transformer的多模态学习最新进展
工业软件讲堂-三维CAD设计软件的核心技术解析----讲坛第二次讲座
Typical application of "stack" - expression evaluation (implemented in C language)
NVIDIA graphics card failed to initialize nvml driver/library version mismatch error solution