当前位置:网站首页>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 .
边栏推荐
猜你喜欢

buuctf misc zip
![[GXYCTF2019]SXMgdGhpcyBiYXNlPw==](/img/4d/f37968ce8ad1cd8112651e4215f464.png)
[GXYCTF2019]SXMgdGhpcyBiYXNlPw==
![Xshell can only input the public key solution [personal test] when connecting to the virtual machine](/img/a9/2c315f92cef46976353b52fb1d0fba.png)
Xshell can only input the public key solution [personal test] when connecting to the virtual machine

【taro】taro微信小程序input在苹果手机上光标聚焦不对的解决办法
![[an Xun cup 2019] blowing bass to sweep QR code](/img/38/7bfa5e9b97658acfe24d3aab795bce.png)
[an Xun cup 2019] blowing bass to sweep QR code

数据治理的重要性
![[set static route]](/img/55/5b35e86b7aa8153d0a2061ab4dfcb7.png)
[set static route] "WiFi for private internal network and external network“

Meet webassembly again

【next】nextjs打包出现组件定义缺少显示名称【Component definition is missing display name】

Npdp| how to do well in product life cycle management?
随机推荐
Document. How to use and listen for readyState
Overview of embedded system and embedded design software
JVM makes wheels
样本方差为什么除以(n-1)
leetcode 279. Perfect squares (medium)
干技术的,追求啥?
滴滴工程效能平台建设之路
Blazor data binding
[golang] cannot convert expression of type 'interface{}' to type 'string' (solution)
[set static route] "WiFi for private internal network and external network“
数学知识:约数之和—约数
Visualization of camera pose
Error in jsonobject getting date type (getsqldate)
如何优雅的统计代码耗时
【Try to Hack】nmap
Meet webassembly again
buuctf pwn ciscn_ 2019_ n_ eight
关于一次Web线下面试的思考
Appium gets the exception of displaying spaces in the middle of object text through XPath
Arm32 instruction parsing general register