<audio @play="onPlay"
@pause="onPause"
:src="playUrl" controls ref="audio"></audio>
<script>
export default {
name:"audio",
data(){
return{
isPlay:false,
playUrl:"https://music.163.com/song/media/outer/url?id=35625825"
}
},
methods:{
handle(){
if(this.isPlay){
this.$refs.audio.pause()
this.isPlay = false
}else{
this.$refs.audio.play()
this.isPlay = true
}
},
onPlay(){
this.isPlay = true
},
onPause(){
this.isPlay = false
},
getDom(){
console.log(this.$refs.music)
}
}
}
</script>