public index.html里面加一个cdn
<script src="https://cdn.bootcss.com/hls.js/8.0.0-beta.3/hls.min.js"></script>
home.vue
<div class="player">
<div id="dplayer" style="width:600px;height:400px"></div>
</div>
mounted() {
this.initDeplayer();
},
methods: {
initDeplayer() {
const dp = new DPlayer({
container: document.getElementById("dplayer"),
autoplay: true,
theme: "#FADFA3",
loop: false,
lang: "zh-cn",
screenshot: true,
hotkey: true,
video: {
url:
"https://api.prprpr.me/dplayer/",
type: "hls"//重点添加
}
});
},
}