Implementation Code of vue2.0 sibling component (level-level) Communication, vue2.0 component
1. Foreplay
Let's take a look at the first two articles:
Parent component to child component
Child component to parent component
Look at the picture to see the picture !!!
Personal Understanding:
This is obviously because the younger brother calls his brother, and both sides need a mobile phone and a signal tower.
- Younger brother => component
- Brother => B Components
- Younger brother's mobile phone =>$ emit sends data
- Brother's mobile phone =>on on listens and receives data
- Signal Transmitting Tower => intermediate event line
- App. vue => Needless to say, we all know that it is the earth.
2. Code
2.1 create an intermediate event line ligature. js under src/asstes (note the suffix. js)
import Vue from 'Vue'export default new Vue;
2.2 create A. vue in src/components
<Template> <div>
2.3 create B. vue in src/components
<Template> <div>
2.4 modify App. vue (EARTH), register these two components, and add tags for these two components.
<template> <div id="app"> <A/>
3. Effect
Summary
The above is the implementation code of the vue2.0 sibling component (level-1) communication introduced by xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!