vue的背景音乐

背景音乐用的是audio标签

在使用audio标签时,他不会自动播放,受播放器的限制,需要用户互动,这里我写个dome,复制即用

//页面
<template>
     <div @click="handleClick">off/on</div>//这里可以用个图标
        <div v-if="shoes">
          <div v-html='audios'> </div>
        </div>
	</template>


//data定义
 data:{
    shoes:false,
     audios:'',
}

//交互
handleClick(){
if(this.shoes == false){
    this.shoes = true;
    this.audios='<head><audio src="https://win-web-rg01-sycdn.kuwo.cn/fb2ded11652cc69d6aec39cd7f233b00/6000f554/resource/n2/93/96/1872412330.mp3" play="true" loop="true" autoplay="autoplay"/>  </head>';
}else if(this.shoes ==true){
     this.shoes = false;
    this.audios="";
}
    
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值