update vue3

This commit is contained in:
Harvey Zack committed 2023-01-19 17:30:33 +08:00
1 parent 181121a36d
commit 38ad57192d
1 file changed
+22 -22
@@ -2,35 +2,35 @@
<div ref="artRef"></div> <div ref="artRef"></div>
</template> </template>
<script> <script setup>
import Artplayer from 'artplayer'; import Artplayer from 'artplayer';
import { ref, onMounted, onBeforeUnmount, nextTick } from 'vue';
export default { const emit = defineEmits(['get-instance']);
data() {
return { const props = defineProps({
instance: null,
};
},
props: {
option: { option: {
type: Object, type: Object,
required: true, required: true,
}, },
}, });
mounted() {
this.instance = new Artplayer({
...this.option,
container: this.$refs.artRef,
});
this.$nextTick(() => { const instance = ref(null);
this.$emit('get-instance', this.instance); const artRef = ref(null);
onMounted(() => {
instance.value = new Artplayer({
...props.option,
container: artRef.value,
}); });
}, nextTick(() => {
beforeUnmount() { emit('get-instance', instance.value);
if (this.instance && this.instance.destroy) { });
this.instance.destroy(false); });
onBeforeUnmount(() => {
if (instance.value) {
instance.value.destroy(false);
} }
}, });
};
</script> </script>