<div id="player"></div>
<script>
new Vue({
el: '#player',
data() {
return {
vodPlayerJs: 'https://player.polyv.net/script/player.js',
vid:'88083abbf5b42072ec029201d9fee095_8',
};
},
mounted(){
this.loadPlayerScript(this.loadPlayer);
},
methods: {
loadPlayerScript(callback) {
if (!window.polyvPlayer) {
const myScript = document.createElement('script');
myScript.setAttribute('src', this.vodPlayerJs);
myScript.onload = callback;
document.body.appendChild(myScript);
} else {
callback();
}
},
loadPlayer() {
const polyvPlayer = window.polyvPlayer;
this.player = polyvPlayer({
wrap: '#player',
vid: this.vid ,
autoplay:false
});
}
},
destroyed() {
if (this.player) {
this.player.destroy();
}
}
})
</script>