当前位置:网站首页>Communication problems in parent and child components of uniapp
Communication problems in parent and child components of uniapp
2022-06-25 04:20:00 【Robin Luo Bing】
1、DOM in Property and Attribute The difference between
property yes DOM Properties in , yes JavaScript The object in ;
attribute yes HTML Features on labels , Its value can only be a string ;
https://www.cnblogs.com/elcarim5efil/p/4698980.html
https://www.jb51.net/article/50686.htm
https://blog.csdn.net/losedguest/article/details/112462253
2、uniapp Parent component in 、 Child components
components The components in are sub components ,pages The component in is the parent component . It can also be understood as components The components in are templates 、 object ; and pages The components in are instances .
A、
The parent component passes through the of the child component props Transfer data to subcomponents ;
In the component template sync Modifier can play a role “ Two way binding ” The effect of ;( Case study :https://m.yisu.com/zixun/178738.html,https://blog.csdn.net/badmoonc/article/details/82876294?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_baidulandingword-0&spm=1001.2101.3001.4242)
Parent component passed ref Property to get the data of the sub component directly (data);
Can pass uni.$emit() The second parameter of the passes a value to the parent component , for example $emit('enlarge-text', 0.1).
B、 Subcomponent pass uni.$emit() Triggering event , Passing events to the parent component ; Parent component passed uni.$on() Listen for sub component events .
C、 The purpose of the slot is to change the template of the child component through the parent component template , Subcomponent pass <slot></slot> Tag to define where the parent component is inserted
https://ask.dcloud.net.cn/article/36010
3、 stay Vue in , The relationship between parent and child components can be summarized as props down, events up. Parent component passed props Pass data down to subcomponents , Subcomponent pass events Send message to parent component .
Subcomponents can be built-in by calling $emit Method and pass in the event name to trigger an event , Parent component passed v-on To listen for sub component events
<button v-on:click="$emit('enlarge-text')">
Enlarge text
</button>
4、uni-app Package of components —— Transmission of events between parent and child components
(1) If the event code of the component is consistent after multiple calls , And the data passed by the parent component is not modified . Write events uniformly in the component .
(2) If the event code of the component is inconsistent after multiple calls , Or the data passed by the parent component needs to be modified . Use custom events : $emit(“ Event name ”, Parameters );
边栏推荐
- Flutter Builder & futurebuilder components
- Development of trading system (II) -- market data
- 数学分析_笔记_第3章:极限
- Win10 environment phpstudy2016 startup failure record
- opencv是开源的吗?
- 1.初识半音阶口琴
- Nodejs 通过Heidisql连接mysql出现ER_BAD_DB_ERROR: Unknown database 'my_db_books'
- Laravel document sorting 2. Route related
- 警惕超范围采集隐私-移动APP违规十宗罪
- openmmlab-环境配置
猜你喜欢

数字时代的“文艺复兴”?起底数字藏品,让人欢喜让人愁

Coinlist queuing tutorial to improve the winning rate

Read lsd-slam: large scale direct monolithic slam

Intel 13代酷睿首次露出真面目:68MB缓存提升明显

Development of trading system (V) -- Introduction to Sinovel counter

2. play the chromatic harmonica

Development of trading system (III) - risk control system

无法安装redis接口

论文阅读《LSD-SLAM: Large-Scale Direct Monocular SLAM》

Error 1062 is reported during MySQL insertion, but I do not have this field.
随机推荐
Monitoring pancakeswap new token
冷热酸甜、想成就成?冷酸灵母公司登康口腔欲在深交所主板上市
Lecture record: new application of inertial navigation - inertial measurement
代表多样性的彩色 NFT 系列上线 The Sandbox 市场平台
Development of trading system (VIII) -- Construction of low delay network
[proteus simulation] Arduino uno key controls the flashing increase / decrease display of nixie tube
web3.eth. Getpendingtransactions() returns null?
Intel 13th generation core showed its true colors for the first time: 68mb cache improved significantly
acmStreamOpen返回值问题
Vigilance against over range collection of privacy - ten mobile app violations
Zoran community
AI quantitative transaction (I) -- Introduction to quantitative transaction
Numpy NP tips: use OpenCV to interpolate and zoom the array to a fixed shape cv2 resize(res, dsize=(64, 64), interpolation=cv2. INTER_ CUBIC)
Qt编译数据库插件通用步骤说明
"How to carry out industrial positioning" in local / Park industrial planning
论文阅读《LSD-SLAM: Large-Scale Direct Monocular SLAM》
How many images can opencv open?
The 5th series of NFT works of missing parts was launched on the sandbox market platform
Hot and cold, sweet and sour, want to achieve success? Dengkang oral, the parent company of lengsuanling, intends to be listed on the main board of Shenzhen Stock Exchange
代錶多樣性的彩色 NFT 系列上線 The Sandbox 市場平臺