src/bus.js

import Vue from 'vue'
export default new Vue()

 

src/main.js

import Bus from '@/lib/bus'     // 引入Bus组件
Vue.prototype.$bus = Bus

 

components01.vue 监听

this.bus.$on('changeValue', (msg, val) => {
                console.log(333, msg, val)
            })

 

components02.vue  传值 并 触发 方法

this.bus.$emit('changeValue', 'hello', 'word')

 

 

 

 

.

 

相关文章:

  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2021-07-30
  • 2021-12-02
相关资源
相似解决方案