When it comes to component communication, there are probably five types that are familiar to everyone: 1. From father to sonThe parent component passes values to the child component through custom attributes, and the child component receives them using props 2. From son to fatherThe parent component customizes the event on the child component tag, and the child component triggers the custom event through $emit and can pass parameters 3. Non-parent-child component value transfer eventBus event bus: Information can be published and subscribed through eventBus (creating an event bus that everyone can access) 4. vuexVuex is a state management mode developed specifically for Vue.js applications. It uses a centralized storage manager to manage the status of all components of the program and solve multi-component communication. However, it is mostly used in medium and large projects, and it will appear bloated in small projects. 5. RefsBy adding ref and ·$refs·, you can also easily get the child component and access the properties and methods of the child component. Regarding refs, I have also written a separate article with detailed usage, the usage of refs In addition to the above 5, there are 5 less common component communication methods: 6. $children In the parent component, $children returns a component collection. If you know the order of the child components, you can also use the subscript operation 7. $parent In the child component For example: 8. provide & inject Appear in pairs : provide and inject appear in pairs Function : Used by parent components to pass data to descendant components Directions:
9. $attrsUsed by parent components to pass data to grandchild components 10. $listeners Used by grandchild components to pass data to parent components 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:
|
<<: Docker5 full-featured harbor warehouse construction process
>>: Introduction to the use of data custom attributes in HTML and plug-in applications
Learning to use CSS3's 3D effects to create a...
<br />Original article: http://www.alistapar...
1 Introduction Redis is a high-performance NoSQL ...
Table of contents Thoughts triggered by an online...
I don't expect to be an expert DBA, but when ...
1. Run the .sh file You can run it directly using...
Today I suddenly thought that the styles of check ...
Product designers face complex and large manufactu...
Apache Tomcat is an open source software that imp...
Table of contents 1. What kind of backup is a dat...
I have always wanted to learn about caching. Afte...
The project has been suspended recently, and the ...
When implementing this function, the method I bor...
1. Command Introduction The passwd command is use...
How to check the file system type of a partition ...