npm install @vueuse/sound -d
//导入播放组件库
import { useSound } from '@vueuse/sound';
//资源地址
import stopMusic from '@/assets/svgs/stop.wav';
import alarmMusic from '@/assets/svgs/alarm.wav';
const stopMusicU = useSound(stopMusic, { volume: 0.25,loop:true })
const alarmMusicU = useSound(alarmMusic, { volume: 0.25,loop:true })
//播放音乐
const playStopMusic = () =>{
stopMusicU.play()
}
const stopStopMusic = () =>{
stopMusicU.stop()
}
const playAlarmMusic = () =>{
alarmMusicU.play()
}
const stopAlarmMusic = () =>{
alarmMusicU.stop()
}