当前位置:网站首页>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 );
边栏推荐
- Uniapp makes mobile app programs, using uni Choosevideo record video, video playback is fuzzy, and the resolution is low
- Flutter Builder & FutureBuilder组件
- Upgrade cmake
- Read lsd-slam: large scale direct monolithic slam
- Simple integration of client go gin -update
- Development of trading system (VI) -- HFT high frequency trading
- Color NFT series representing diversity launched on the sandbox market platform
- uniapp 制作手机app程序, 使用uni.chooseVideo录制视频,视频播放模糊分辨率低的原因
- LeetCode 剑指Offer II 091 粉刷房子[动态规划] HERODING的LeetCode之路
- 【LeetCode】148. Sort linked list
猜你喜欢

95% 程序员都在这里摸鱼……

《Missing Parts》NFT 作品集第 5 系列上线 The Sandbox 市场平台

Flutter FittedBox组件

代表多样性的彩色 NFT 系列上线 The Sandbox 市场平台

How to draw an industry investment map

1、项目第二阶段——用户注册和登陆

Development of trading system (VII) -- Analysis of trading delay
佐喃社区

Is opencv open source?

Intel 13th generation core showed its true colors for the first time: 68mb cache improved significantly
随机推荐
【LeetCode】143. 重排链表
Simple integration of client go gin 11 delete
PHP code audit 2 - these functions must be known and understood
Smart contract learning materials
Where is the red area of OpenCV?
Development of trading system (XIII) -- Analysis of quickfix source code
Development of trading system (III) - risk control system
SQL, CTE, FLG CASE问题
DAP data scheduling function improvement description
[proteus simulation] Arduino uno key controls the flashing increase / decrease display of nixie tube
讲座记录《多种空间大地测量技术的数据处理方法和应用》
代錶多樣性的彩色 NFT 系列上線 The Sandbox 市場平臺
地方/园区产业规划之 “ 如何进行产业定位 ”
警惕超范围采集隐私-移动APP违规十宗罪
Watch out for the stolen face! So many risks of face recognition used every day?
numpy np tips: numpy数组的squeeze等处理
虽然传统意义上的互联网早已不复存在,但这并不代表互联网早已消失不再
长沙“求才”:“下力气”与“出实招”并进,“快发展”和“慢生活”兼得
95% 程序员都在这里摸鱼……
Simple integration of client go gin -update