一, 新增一个中间组件内容, 在src 下的component 下新建一个JS文件
// 内容写入如下
import Vue from 'Vue'
export default new Vue;
二, 在获取数据的页面引入改中间组件
import WechatDown from './components/WechatDown'
// 引入刚刚新建的js 文件
import bus from "@/components/eventBus/index.js";
export default {
三, 保存对应的数据到中间组件
//监听A组件中的spot,并发送数据
bus.$emit("spot", this.seller)
四, 在其他页面中调用中间组件内容
// 引入中间件
import bus from "@/components/eventBus/index.js";
// 接收兄弟组件获取的数据内容
mounted() {
var _this = this;
//监听A组件中的spot,并接受数据
bus.$on("spot", function(data) {
_this.seller = data;
});
},