Files
ArtPlayer/packages/artplayer-template/nuxt.js/Artplayer.vue
T
2022-11-04 20:55:17 +08:00

37 lines
686 B
Vue

<template>
<div ref="artRef"></div>
</template>
<script>
import Artplayer from 'artplayer';
export default {
data() {
return {
instance: null,
};
},
props: {
option: {
type: Object,
required: true,
},
},
mounted() {
this.instance = new Artplayer({
...this.option,
container: this.$refs.artRef,
});
this.$nextTick(() => {
this.$emit('get-instance', this.instance);
});
},
beforeUnmount() {
if (this.instance && this.instance.destroy) {
this.instance.destroy(false);
}
},
};
</script>