背景音乐

添加背景音乐 并有单击事件   循环播放

 

<template>
    <div id="page">
        <div style="width: 100%" class="flex-container column">
            <video id="video" src="../static/audios/bgm3.mp3" controls="controls" hidden="hidden" autoplay="autoplay"  loop="loop"> </video>

            <img  id="img" class="play" style="transform: translate(-1584.4%, 121.5%) scale(1)" :src="sound" @click="play()">

        </div>
    </div>
</template>


<script>
 export default {
        data() {
            return {
                sound: require('../static/img/33.png'),
        },
         methods: {
            play(){
                let vo = document.getElementById("video")
                if(this.sound == require('../static/img/33.png')){
                    this.sound = require('../static/img/22.png')
                    vo.autoplay = true
                    vo.play()
                }
                else{
                    this.sound = require('../static/img/33.png')
                    vo.pause()
                }

            }
}
</script>

 

目录结构

vue 页面 添加背景音乐

 

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-08-07
  • 2022-12-23
  • 2021-05-30
猜你喜欢
  • 2021-04-25
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案