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)
Table of contents Preface 🍹Preparation 🍲vue3 usag...
Table of contents User Management Create a new us...
The ECS cloud server created by the historical Li...
Common Convention Tags Self-closing tags, no need...
Table of contents 1. Shared and Exclusive Locks 2...
The virtual machine I rented from a certain site ...
1. Necessity of Tuning I have always been reluct...
Software version and platform: MySQL-5.7.17-winx6...
This article example shares the specific code of ...
Vuex is a state management pattern developed spec...
I'm playing with big data recently. A friend ...
The process of completely uninstalling the MySQL ...
ERROR 1290 (HY000) : The MySQL server is running ...
How to convert a JSON string into a JSON object? ...
Table of contents Congruent and Incongruent congr...