Vue3+APlayer的小案例
<template>
<div id="aplayer"></div>
</template>
<script>
import 'aplayer/dist/';
import APlayer from 'aplayer';
export default {
name: 'HomeView',
components: {
},
mounted() {
this.addMyAudio();
},
data(){
return{
audio: [{
name: "China-Y",//歌名
artist: '徐梦圆',//歌手
url: 'https:///down/59298.mp3down/39868.mp3',//音频文件地址
cover: '/stdmusic/150/20170815/',//音乐封面地址
lrc: ""// 歌词
}]
}
},
methods:{
addMyAudio() {
const ap = new APlayer({
container: document.getElementById("aplayer"),
audio: this.audio
})
}
}
}
</script>