【发布时间】:2021-04-28 10:33:08
【问题描述】:
跟随basic example in the docs,但没有播放声音。我在 Network 选项卡中看到了 mp3 文件,但它是 90KB 而不是 5MB,所以我想它不能正确加载。
我尝试了不同的路径:src: ['@/assets/audios/test.mp3'], `src: ['../assets/audios/test.mp3']。没有任何效果。没有控制台错误。为什么它不起作用?
<template>
<div class="container">
<button @click="play">
PLAY
</button>
</div>
</template>
<script>
import { Howl, Howler } from 'howler'
export default {
data () {
return {
sound: ''
}
},
mounted () {
this.sound = new Howl({
src: ['test.mp3']
})
},
methods: {
play () {
this.sound.play()
}
}
}
</script>
【问题讨论】:
-
你是从网络服务器上运行的吗?