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)
Without going into details, let's go straight...
1.Write in front: As a lightweight virtualization...
There is a task process on the server. When we us...
This article example shares the specific implemen...
This article shares the specific code for the WeC...
Table of contents 1 Question 2 Methods 3 Experime...
Table of contents Basic application of javascript...
This article shares the specific code of JS canva...
Table of contents 1. Preparation 2. Introduction ...
In the process of writing the project page, I enc...
1.core file When a Segmentation fault (core dumpe...
Nginx can not only hide version information, but ...
Table of contents 1. RegExp object 2. Grammar 2.1...
Recently, I have a need to list all host names in...
If you are not committed to becoming an artist, t...