首先在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刪除。