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
Table of contents 1. Component Organization 2. Co...
Think big and small, then redirect. Sometimes Lin...
Table of contents infer Case: Deepen your underst...
Table of contents What are immutable values? Why ...
Table of contents 1. What is 2. Use Numeric Enume...
Install Ubuntu 20.04 Install NVIDIA drivers Confi...
Table of contents What is Routing Basic use of pu...
There are two ways to achieve read-only input: dis...
engine Introduction Innodb engine The Innodb engi...
Preface This article mainly introduces the releva...
Deploy redis in docker First install Docker in Li...
1. Introduction Is it considered rehashing old st...
Before talking about CSS priority, we need to und...
Table of contents 1. Introduction to Slow Log 2. ...
Seamless carousel is a very common effect, and it...