eventBus

eventBus.js

import Vue from 'vue'
const eventBus = new Vue();
export default eventBus;

用法
a.vue页面

import eventBus from './eventBus.js'//引入
fun(){
	eventBus.$emit('change',1)
}

b.vue页面接收

import eventBus from './eventBus.js'//引入
onLoad() {
	eventBus.$on('change', res => {
		console.log(res)//1
	});
}

你可能感兴趣的:(uniapp,vue,vue.js,前端,uni-app)