@play、@pause、@ended都是自带的事件,一开始不知道整了半天
<div >
<audio controls autoplay @play="play" @pause="pause" @ended="audioEnded" :src="require('@/assets/Listen_material/'+imgANDaudioIndex+'.mp3')" ></audio>
</div>
js部分
methods:{
play(){
this.isPlaying=true;
console.log("running~")
},
pause(){
this.isPlaying=false;
console.log("stop!")
},
audioEnded(){
console.log('end')
Toast.success('任务完成!');
setTimeout(() => {
this.$router.go(-1)
}, 2000);
},
},