需要使用hls插件
首先安装依赖npm install hls.js --save
<audio ref="audio"></audio> import Hls from 'hls.js'; methods: { init(){ if (Hls.isSupported()) { var hls = new Hls();// 实例化 Hls 对象 hls.loadSource('https://s.music.com/s/000000000/000_00000.m3u8');// 传入路径 hls.attachMedia(this.$refs.audio); hls.on(Hls.Events.MANIFEST_PARSED, () => {//加载成功 setTimeout(() => { console.log(this.$refs.audio) this.$refs.audio.play();// 调用播放 API }, 0) }); } } }