vue bus 使用

vue bus 使用

1. 定义bus

import Vue from 'vue'

const Bus = new Vue();

export default Bus;

2.导入

// 导入bus
import bus from './Bus'

Vue.prototype.bus = bus;

3.使用

//Component List
this.bus.$emit('goodInfo',res.data);
//Component Add
this.bus.$on('goodInfo', msg => {
    
    
	console.log(msg)
}

猜你喜欢

转载自blog.csdn.net/weixin_41481695/article/details/114386414