Files
ArtPlayer/packages/artplayer-template/nuxt.js/Artplayer.vue
T
2022-05-06 10:46:17 +08:00

36 lines
685 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>