当前位置:网站首页>鸿蒙第四次学习
鸿蒙第四次学习
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方法并接收子组件传递的参数。
边栏推荐
- Memory mapping of QT
- Meta universe chain game system development (logic development) - chain game system development (detailed analysis)
- Unity learning shader notes [82] black and white processing of enhanced single channel color rendering
- NVIDIA graphics card failed to initialize nvml driver/library version mismatch error solution
- SAP S/4HANA OData Mock Service 介绍
- 如何清理废弃pv和其对应的文件夹
- RTE11- 中断解耦功能
- 实施阴影介绍
- Wechat nucleic acid detection appointment applet system graduation design completion (4) opening report
- Picking up the camera is the best artistic healing
猜你喜欢
Redis(7)----数据库与过期键
Leetcode 面试题 16.11. 跳水板
300+ documents! This article explains the latest progress of multimodal learning based on transformer
Wechat nucleic acid detection appointment applet system graduation design completion (4) opening report
夜神模擬器+Fiddler抓包測試App
SteamOS 3.3 Beta 发布,Steam Deck 中文键盘终于来了
又一所双非改考408,会爆冷么?南昌航空大学软件学院
A good programmer is worth five ordinary programmers!
300+篇文献!一文详解基于Transformer的多模态学习最新进展
UE4 用spline畫正圓
随机推荐
Which securities company has a low, safe and reliable online account opening commission
消除IBM P750小机上的黄色报警灯[通俗易懂]
能解决80%故障的排查思路
Nm02 nm module call sequence diagram and code interpretation independent of bus protocol
微信小程序视频分享平台系统毕业设计毕设(1)开发概要
2020 Internet industry terminology
怎么用ps提取图片颜色分析色彩搭配
Redis(7)----数据库与过期键
Wechat nucleic acid detection appointment applet system graduation design completion (5) task statement
Pit encountered during installation of laravel frame
What is cloud primordial? This time, I can finally understand!
“栈”的典型应用—表达式求值(C语言实现)
A4988 and 42 stepper motors
Rte11 interrupt decoupling function
Relax again! These fresh students can settle directly in Shanghai
ESP32-C3入门教程 问题篇⑩——error: implicit declaration of function ‘esp_blufi_close‘;
微信小程序视频分享平台系统毕业设计毕设(6)开题答辩PPT
UE4 用spline畫正圓
Is Guojin securities a state-owned enterprise? Is it safe to open an account in Guojin securities?
饭卡 HDU2546