使用vue3-eventbu或mitt ,vue版本为3以上
接收值接收在=>不能多个参数,只能一个
mounted() {
this.player = videojs(this.$refs.videoPlayer, this.options, function onPlayerReady() {
console.log('onPlayerReady', this);
}),
bus.on('foo', (e) =>
//console.log(e)
this.player.src({src:e ,type:'application/x-mpegURL'}) //只能一个参数
//this.player.play
//this.player.src=e
)
},
传值
countPlayer(){
var store = createStore();
console.log("222",this.videoOptions.sources[0].src);
this.videoOptions.sources[0].src=this.urls;
console.log("333",this.videoOptions.sources[0].src);
bus.emit('foo', this.urls) //传值
}