1. In project development, the most common relationships between components are divided into the following two types: 1. Father-son relationship 2. Brotherly Relationship 1.1 Data sharing between parent and child componentsData sharing between parent and child components is divided into: 1. Parent->Child Shared Data Subcomponents: Parent component: 2. Child->Parent Shared Data Child components share data with parent components using custom events. The sample code is as follows Subcomponents: Parent component: The page displays the results: 1.2 Data sharing between sibling componentsIn vue2.x, the solution for sharing data between sibling components is EventBus EventBus usage:
Example: 1. Create the eventBus.js module and share a Vue instance object 2. On the data sender, call bus.$emit('event name', data to be sent) method to trigger a custom event 3. On the data receiver side, call bus.$on('event name', event processing function) method to register a custom event SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: The process of installing Docker on Windows Server 2016 and the problems encountered
>>: Html Select option How to make the default selection
Vue implements the palace grid rotation lottery (...
Table of contents 1. When inserting or modifying ...
1. The three files /etc/hosts, /etc/resolv.conf a...
Preface smb is the name of a protocol that can be...
1. Install Howdy: howdy project address sudo add-...
Table of contents Common key aliases Key without ...
It's the end of the year and there are fewer ...
For some systems with large amounts of data, the ...
Nginx can generally be used for seven-layer load ...
Google's goal with Flutter has always been to...
SQL is the main trunk. Why do I understand it thi...
Table of contents Preface: 1. Install Docker 2. I...
Table of contents Preface 1. Preparation - Server...
Table of contents 1. Initial SQL Preparation 2. M...
glibc is the libc library released by gnu, that i...