vue 自带的 bus 事件使用


 

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')

 

 

 

 

.

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM