当前位置:网站首页>第二次作业笔记
第二次作业笔记
2022-06-23 03:49:00 【qq_20521729】
JS UI框架支持自定义组件,用户可根据业务需求将已有的组件进行扩展,增加自定义的私有属性和事件,封装成新的组件,方便在工程中多次调用,提高页面布局代码的可读性。
定义一个专门存放自定义组件的文件夹 components.tabbar 并设置3个基础文件 tabbar.hml、tabbar.js、tabbar.css,需要注意的是:3个文件的文件名必须保持一致,不然会存在找不到文件的情况。该自定义组件的目的是给页面底部配置一个 tabbar 选项卡体验。
设置底部选项卡对应的 json 数据源,用来保存 icon 图片、标题,以及点击选中后的 icon 图片。
- 导入 tabbarItem 数据,并设置对应 data ,同时设置点击事件 动态设置点击对应 icon 选中。
- 设置 CSS 样式 将 tabbar 选项卡置底「tabbar.css」
自定义组件是用户根据业务需求,将已有的组件组合,封装成的新组件,可以在工程中多次调用,提高代码的可读性。
自定义组件通过element引入到宿主页面,使用方法:name 属性指自定义组件名称(非必填),组件名称对大小写不敏感,默认使用小写,src 属性指自定义组件hml 文件路径(必填),若没有设置 name 属性,则默认使用 hml 文件名作为组件名。
事件绑定:自定义组件中绑定子组件事件使用 (on|@)child1 语法,子组件中通过 this.$emit('child1', { params: '传递参数' }) 触发事件并进行传值,父组件执行 bindParentVmMethod 方法并接收子组件传递的参数。
Props 自定义组件可以通过 props 声明属性,父组件通过设置属性向子组件传递参数,camelCase(驼峰命名法)的 prop 名,在外部父组件传递参数时需要使用 kebab-case (短横线分隔命名)形式,即当属性compProp 在父组件引用时需要转换为 comp-prop。
添加默认值,子组件可以通过固定值 default 设置默认值,当父组件没有设置该属性时,将使用其默认值。此情况下 props 属性必须为对象形式,不能用数组形式。
数据单向性,父子组件之间数据的传递是单向的,只能从父组件传递给子组件,子组件不能直接修改父组件传递下来的值,可以将 props 传入的值用 data 接收后作为默认值,再对 data 的值进行修改。
边栏推荐
猜你喜欢

LabVIEW在同一表中同时显示十六进制字符和普通字符

X24cxx series EEPROM chip C language universal reading and writing program
![[multimode] unimo](/img/a5/a857e20e1432ef3623527c8655a49a.png)
[multimode] unimo

仿360桌面悬浮球插件

Zhongang Mining: the demand for fluorite in the new energy and new material industry chain has increased greatly

Compilation, installation and global configuration section description of haproxy

Flutter series: wrap in flutter

What is metadata

It supports running in kubernetes, adds multiple connectors, and seatunnel version 2.1.2 is officially released!
![[deep learning] deep learning reasoning framework tensorrt MNN openvino onnxruntime](/img/a9/11bc00a91b79358f28ada2d4c99f32.png)
[deep learning] deep learning reasoning framework tensorrt MNN openvino onnxruntime
随机推荐
JD cloud distributed database stardb won the "stability practice pioneer" of China Academy of information technology
Prince language under insect date category
Deploying Apache pulsar on kubesphere
什么是元数据
IDEA-导入模块
制造型企业开发的SRM供应商管理系统特点是什么
Zhongang Mining: the demand for fluorite in the new energy and new material industry chain has increased greatly
【二叉樹進階】AVLTree - 平衡二叉搜索樹
[binary tree] completeness test of binary tree
Common interview questions in automated testing
Leetcode 1208. Make strings as equal as possible
在 KubeSphere 上部署 Apache Pulsar
mysql能不能在linux中使用
How node+express operates cookies
SVG+JS智能家居监控网格布局
Basic skills of x64dbg
Halcon胶线检测—模板匹配、位姿变换、胶宽,胶连续性检测
② cocoapods原理及 PodSpec 文件上传操作
PTA: spacing of 7-69 data
Lighthouse locally deployed TCA code analysis tool