there are two components, component An and component B, and there is a player in component A, and the playback and stop events of the player are added, which requires that multiple buttons of component B can also be clicked to allow the player of component A to play. and each click will pause the previous one and immediately play the next
.A
<img :src="start" alt="-sharp" @click="changestart" class="seta">
changestart() {
if (this.start == "../../static/pic/start.png") {
this.start = "../../static/pic/stop.png";
this.$refs.player.play();
} else {
this.start = "../../static/pic/start.png";
this.$refs.player.pause();
}
bclick
<li v-for="(songNamelist,songIndex) in songName" v-bind:key="songIndex" class="songlist" @click="songChoose(songIndex,"/play")">
songChoose(songIndex,z) {
this.$router.replace(z)
this.isresearch = false;
this.ishow=false;
this.keyword="";
},
there is an idea, because Vuex, clicks the B component button and uses mutation to submit and modify state.xxx=true,A components to find the parameter xxx=true of state and then perform playback, but the playback function does not know where to write
this.$refs.player.play()
cannot be written into created, because A has not been reloaded. I don"t know what to trigger when written to A"s methods. Watch has also tried. Xxx does not know where to set it to false,. Please give me a solution or an idea. Thank you very much.