1. Parent components can pass data to child components through props 2. The child component can pass data to the parent component through custom events, the parent component customizes the event, the child component triggers the parent component event, and passes the data 3. Subcomponents can define slots to allow parent components to customize the content to be displayed 4. Use easycom specifications to directly use components <template> <view> <view>Custom component usage specifications</view> <card color="red" @fclick="fclick"></card> <card color="yellow">Yellow component</card> </view> </template> <script> export default { data() { return { } }, methods: { fclick(msg){ console.log('The parent component receives the value passed by the child component: '+msg); } } } </script> <style> </style> Component: <template> <view :style="{background:color}" @click="zclick"> Custom component <slot></slot> </view> </template> <script> export default { name:"card", props:{ color:{ type:String, default:'white' } }, data() { return { }; }, methods:{ zclick(){ console.log('Clicked the subcomponent'); this.$emit('fclick','The click event is passed to the parent component'); } } } </script> <style> </style> SummarizeThis article ends here. I hope it can be helpful to you. I also hope that you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: Implementation of nacos1.3.0 built with docker
>>: Detailed tutorial for installing MySQL 8.0.22 on Redhat 7.3 (binary installation)
1.MySQL replication concept It means transferring...
Table of contents 1. How to obtain elements Get i...
In Vue, we generally have front-end and back-end ...
Table of contents MYSQL METADATA LOCK (MDL LOCK) ...
Table of contents 1. Reverse proxy preparation 1....
I just started learning database operations. Toda...
In the vertical direction, you can set the row al...
FireFox is a commonly used browser with many exte...
Several concepts Line box: A box that wraps an in...
When href is needed to pass parameters, and the p...
Table of contents 1. Introduction 2. MVCC (Multi-...
As front-end engineers, IE must be familiar to us...
Table of contents Find and fix table conflicts Up...
The previous article introduced two methods to ch...
Table of contents docker system df docker system ...