监听音乐播放状态:改变播放或暂停按钮 watchMusicState(){ let _this = this; let $audio = document.getElementsByTagName('audio')[0];//获取音乐DOM节点 let playOrPause = document.getElementsByClassName('playOrPause')[0]; // console.log($audio); $audio.addEventListener("playing", function(){ //播放状态Doing playOrPause.src = require('../assets/img/pause.svg')//背景音乐是播放还是暂停 _this.playState = true;//播放状态 });$audio.addEventListener("pause", function(){ //暂停状态Doing playOrPause.src = require('../assets/img/play.svg')//背景音乐是播放还是暂停 _this.playState = false;//暂停状态 }); },