当前位置:网站首页>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 );
边栏推荐
- 讲座记录《惯性导航的新应用——惯性测量》
- Error 1062 is reported during MySQL insertion, but I do not have this field.
- 佐喃社区
- List rendering in wechat applet
- client-go gin的简单整合十-Update
- 数学分析_笔记_第3章:极限
- BSC smart contract dividend mainstream currency | including marketing wallet | deflation | reflow | dividend free token | available for direct deployment
- 2. play the chromatic harmonica
- Development of trading system (VII) -- Analysis of trading delay
- Coinlist queuing tutorial to improve the winning rate
猜你喜欢
LeetCode 剑指Offer II 091 粉刷房子[动态规划] HERODING的LeetCode之路
Hello CTP (II) -- Introduction to CTP
How many images can opencv open?
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
Mathematical analysis_ Notes_ Chapter 3: limits
[openwrt] we recommend a domestically developed version of openwrt, an introduction to istoreos. It is very easy to use. It is mainly optimized. It solves the problem of Sinicization.
UCLA | 用于黑盒优化的生成式预训练
Development of trading system (I) -- Introduction to trading system
Cesium graphic annotation circle, square, polygon, ellipse, etc
How to quickly deliver high-value software
随机推荐
Development of trading system (III) - risk control system
The 5th series of NFT works of missing parts was launched on the sandbox market platform
Openmmlab environment configuration
Trading system development (IV) - trading counter system
Mysql的order by
@Requestbody solution get parameter is null
【LeetCode】22. bracket-generating
代表多样性的彩色 NFT 系列上线 The Sandbox 市场平台
Sourcetree pulls the code and prompts to fill in authentic, but the configuration cannot change the user
虽然传统意义上的互联网早已不复存在,但这并不代表互联网早已消失不再
MySQL插入过程报错1062,但是我没有该字段。
AI quantitative transaction (I) -- Introduction to quantitative transaction
Turn 2D photos into 3D models to see NVIDIA's new AI "magic"!
LeetCode 剑指Offer II 091 粉刷房子[动态规划] HERODING的LeetCode之路
@RequestBody解决获取参数为null
Laravel document sorting 4. Controller
Win10 environment phpstudy2016 startup failure record
openmmlab-环境配置
Shutter fittedbox component
95% of programmers fish here