首先在main.js中创建一个空的示例,并且将自定义的$bus绑定到原型上
Vue.prototype.$bus = new Vue()
发出方
this.$bus.$emit('fromB', id)
接收方
mounted () { let that = this; that.$bus.$on('fromB', data => { // console.log("接收到的数据:"+data); }) },
首先在main.js中创建一个空的示例,并且将自定义的$bus绑定到原型上
Vue.prototype.$bus = new Vue()
发出方
this.$bus.$emit('fromB', id)
接收方
mounted () { let that = this; that.$bus.$on('fromB', data => { // console.log("接收到的数据:"+data); }) },
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。