vue-bus非父子组件之间触发事件

在main.js 中全局引入

import VueBus from 'vue-bus'
Vue.use(VueBus)

组件监听

this.$bus.emit('eventBusName',obj );

组件事件触发
created(){
            var self = this;
            this.$bus.on('eventBusName', function(val){
                self.play_obj = {
                    curSrc:val.src,
                    curName:val.name,
                    curAuthor:val.author,
                    playStatus:val.status
                };
                self.audioPlay;
            });
        }


你可能感兴趣的:(Vue.js,JavaScript,JavaScript武器库)