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 mysql log files binlog Binlog l...
JavaScript can do a lot of great things. This art...
HTML provides five space entities with different ...
This article shares the specific code of JavaScri...
When connecting to the local database, navicat fo...
Effect There are currently 2 projects (project1, ...
This tutorial shares the installation and configu...
Table of contents Achieve results Implementation ...
Add secure_file_priv = ' '; then run cmd ...
Table of contents Features Preservation strategy ...
Preface HTTP and HTTPS In our daily life, common ...
Table of contents 1. What is a regular expression...
Mysql sets boolean type 1. Tinyint type We create...
How to solve the Mysql transaction operation fail...
Preface This article mainly introduces the releva...