当前位置:网站首页>Harmonyos application development second assignment notes
Harmonyos application development second assignment notes
2022-06-22 00:37:00 【A beginner of Science】
1. Custom components
JS UI The framework supports custom components , Users can expand the existing components according to business requirements , Add custom private properties and events , Package into new components , It is convenient to call... Multiple times in the project , Improve the readability of page layout code .
- Define a folder for storing custom components components.tabbar And set up 3 Base file tabbar.hml、tabbar.js、tabbar.css, It should be noted that :3 The file names of two files must be consistent , Otherwise, the file will not be found . The purpose of this custom component is to configure a... At the bottom of the page tabbar Tab experience .
- Set the corresponding settings for the bottom tab json data source , For preservation icon picture 、 title , And click the selected icon picture .
Custom components are used by users according to business requirements , Combine existing components , Packaged into new components , You can call... Multiple times in a project , Improve the readability of the code .
Custom components are created through element Introduce to the host page , Usage method :
<element name='comp' src='../../components/tabbar/tabbar.hml'></element>
<div class="container">
<text class="title">
home page
</text>
<comp></comp>
</div>name Property refers to the custom component name ( Not required ), Component names are case insensitive , The default is lowercase ,src Properties refer to custom components hml File path ( Required ), If not set name attribute , It is used by default hml Use the file name as the component name .
Event binding : Binding subcomponent events in custom components use (on|@)child1 grammar , Passed in the child component this.$emit('child1', { params: ' Pass parameters ' }) Trigger the event and transfer the value , Parent component execution bindParentVmMethod Method and receive the parameters passed by the subcomponent .
2. Parent-child component communication
Props Custom components can be created by props Declarative attribute , The parent component passes parameters to the child component by setting properties ,camelCase( Hump nomenclature ) Of prop name , When an external parent component passes parameters, it needs to use kebab-case ( Short horizontal lines separate the names ) form , That is, when attribute compProp When the parent component references, it needs to be converted to comp-prop.
Add default , Subcomponents can be defined by fixed values default Set the default value , When the parent component does not set this property , Its default value will be used . In this case props Property must be in object form , It can't be in an array .
Data unidirectionality , The data transfer between parent and child components is one-way , Can only be passed from parent component to child component , The child component cannot directly modify the value passed down by the parent component , Can be props The value passed in is in data As the default value after receiving , Right again data Change the value of .
边栏推荐
- 以父之名活动攻略(可以薅羊毛啦)
- Error in jsonobject getting date type (getsqldate)
- 如何优雅的统计代码耗时
- 【2023提前批 之 面经】~ 青岛鼎信科技
- WMS warehouse management system source code
- [wechat applet] 40029 invalid code solution set
- rabbit:do_run_postlaunch_phase/0 line 932
- rabbit:do_ run_ postlaunch_ phase/0 line 932
- 【yarn】Name contains illegal characters
- Importance of data governance
猜你喜欢

再次认识 WebAssembly
![[an Xun cup 2019] blowing bass to sweep QR code](/img/38/7bfa5e9b97658acfe24d3aab795bce.png)
[an Xun cup 2019] blowing bass to sweep QR code

Im instant messaging source code + software +app with detailed package video building tutorial

Katalon框架测试web(八)等待

Use of MySQL performance analysis tools

Meet webassembly again

程序员坐牢了,会被安排去写代码吗?

【taro】taro微信小程序input在苹果手机上光标聚焦不对的解决办法

Query of the range of the cotolly tree chtolly tree old driver tree

滴滴工程效能平台建设之路
随机推荐
[next] the component definition is missing display name in the next JS package
Brief idea and simple case of JVM tuning - space allocation guarantee mechanism in the old age
ARM32指令解析通用寄存器
以父之名活动攻略(可以薅羊毛啦)
8 种最坑SQL语法,工作中踩过吗?
如何优雅的统计代码耗时
Go Web 编程入门:验证器
【typescript】typscript中感叹号和问号的区别
汇编语言范例
What do technical people pursue?
HMS core machine learning service ID card identification function to achieve efficient information entry
【node】node使用mysql连接池
【微信小程序】获取当前地理纬度和ip
Web应用系统开发的两种流行架构
Katalon framework test web (VIII) wait
Brève idée et cas simple de l'ajustement JVM - mécanisme de garantie de l'allocation de l'espace dans les temps anciens
【yarn】Name contains illegal characters
AttributeError: ‘WebDriver‘ object has no attribute ‘w3c‘
Mathematical knowledge: number of approximations - approximations
Assembly language example