mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 08:51:20 -08:00
update vue3
This commit is contained in:
1 parent
181121a36d
commit
38ad57192d
1 file changed
+27
-27
@@ -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 {
|
|
||||||
instance: null,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
option: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.instance = new Artplayer({
|
|
||||||
...this.option,
|
|
||||||
container: this.$refs.artRef,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$nextTick(() => {
|
const props = defineProps({
|
||||||
this.$emit('get-instance', this.instance);
|
option: {
|
||||||
});
|
type: Object,
|
||||||
|
required: true,
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
});
|
||||||
if (this.instance && this.instance.destroy) {
|
|
||||||
this.instance.destroy(false);
|
const instance = ref(null);
|
||||||
}
|
const artRef = ref(null);
|
||||||
},
|
|
||||||
};
|
onMounted(() => {
|
||||||
|
instance.value = new Artplayer({
|
||||||
|
...props.option,
|
||||||
|
container: artRef.value,
|
||||||
|
});
|
||||||
|
nextTick(() => {
|
||||||
|
emit('get-instance', instance.value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
if (instance.value) {
|
||||||
|
instance.value.destroy(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
Reference in new issue
Block a user