vue add background music

vue add background music need to use HTML in the <auto> tag

Reference: http://www.w3school.com.cn/tags/html_ref_audio_video_dom.asp

 <audio :src="mus" class="media-audio" loop autoplay ref="MusicPlay"></audio>
   

MUS: The require ( "../assets/mus.wav"),   // audio use

/**
       * Pause and stop music rotation
       */
      musicPause() {
        this.$refs.MusicPlay.pause();
        this.musicTF = true;
        if (this.interval !== null) {
          clearInterval(this.interval);
        }
      },

      /**
       * Play music and begins to rotate
       */
      musicPlay() {
        this.$refs.MusicPlay.play();
        this.musicTF = false
        this.countMusicNum();
      },

Since the start button control elsewhere, so the ref pointing with auto

 

Guess you like

Origin www.cnblogs.com/zouwangblog/p/11097564.html