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

边栏推荐
- QQmlApplicationEngine
- 国金证券是国企吗?在国金证券开户资金安全吗?
- Web版3D可视化工具,程序员应该知道的97件事,AI前沿论文 | 资讯日报 #2022.07.01
- 300+ documents! This article explains the latest progress of multimodal learning based on transformer
- Unity learning shader notes [82] black and white processing of enhanced single channel color rendering
- 微信小程序视频分享平台系统毕业设计毕设(1)开发概要
- SAP S/4HANA OData Mock Service 介绍
- Wechat applet video sharing platform system graduation design completion (1) development outline
- 一款简约PHP个人发卡程序V4.0版本
- Leetcode interview question 16.17 Continuous sequence
猜你喜欢

Steamos 3.3 beta release, steam deck Chinese keyboard finally came

UE4 用spline畫正圓

微信小程序视频分享平台系统毕业设计毕设(6)开题答辩PPT

Wechat nucleic acid detection appointment applet system graduation design completion (1) development outline

Web版3D可视化工具,程序员应该知道的97件事,AI前沿论文 | 资讯日报 #2022.07.01

Wechat applet video sharing platform system graduation design completion (5) assignment

Pychar modify pep8 e501 line too long > 0 characters

Nm01 function overview and API definition of nm module independent of bus protocol

Simulateur nightGod + application de test de capture de paquets Fiddler

Leetcode 面试题 16.11. 跳水板
随机推荐
300+ documents! This article explains the latest progress of multimodal learning based on transformer
Unity学习shader笔记[八十二]增强单通道颜色渲染的黑白处理
Détends - toi encore! Ces nouveaux étudiants peuvent s'installer directement à Shanghai
Unity学习shader笔记[八十一]简单的颜色调整后处理(亮度,饱和度,对比度)
Wechat applet video sharing platform system graduation design (3) background function
RDK simulation experiment
SteamOS 3.3 Beta 发布,Steam Deck 中文键盘终于来了
Ue4 dessine un cercle avec une ligne de contour
Ali was wildly asked by the interviewer on three sides. Redis dared not write 'proficient' on his resume anymore
Leetcode interview question 16.17 Continuous sequence
ESP32-C3入门教程 问题篇⑪——esp-tls: create_ssl_handle failed, tls_io_instance->options.trusted_certs null
options should NOT have additional properties
Night God simulator +fiddler packet capture test app
任职 22 年,PowerShell 之父将从微软离职:曾因开发 PowerShell 被微软降级过
Three methods of MySQL backup
Uncover the whole link communication process of dewu customer service im
UE4 用spline畫正圓
Leetcode(154)——寻找旋转排序数组中的最小值 II
QQmlApplicationEngine
Wechat applet video sharing platform system graduation design completion (6) opening defense ppt