🐛(component): 修复 upload 事件注册警告

This commit is contained in:
就眠儀式 2022-10-14 10:22:56 +08:00
parent c8bbc86194
commit 91f9ee78fa

View File

@ -13,6 +13,7 @@ import {
getCurrentInstance, getCurrentInstance,
nextTick, nextTick,
onMounted, onMounted,
onUnmounted,
ref, ref,
useSlots, useSlots,
withDefaults, withDefaults,
@ -21,6 +22,7 @@ import { templateRef } from "@vueuse/core";
import { LayLayer } from "@layui/layer-vue"; import { LayLayer } from "@layui/layer-vue";
import LayButton from "../button/index.vue"; import LayButton from "../button/index.vue";
import Cropper from "cropperjs"; import Cropper from "cropperjs";
import { unescapeMd } from "markdown-it/lib/common/utils";
export interface LayerButton { export interface LayerButton {
text: string; text: string;
@ -379,11 +381,21 @@ function dragOver(e: any) {
onMounted(() => { onMounted(() => {
nextTick(() => { nextTick(() => {
dragRef.value.addEventListener("dragenter", dragEnter, false); if(dragRef.value) {
dragRef.value.addEventListener("dragover", dragOver, false); dragRef.value.addEventListener("dragenter", dragEnter, false);
dragRef.value.addEventListener("drop", uploadChange, false); dragRef.value.addEventListener("dragover", dragOver, false);
dragRef.value.addEventListener("drop", uploadChange, false);
}
}); });
}); });
onUnmounted(() => {
if(dragRef.value) {
dragRef.value.removeEventListener("dragenter");
dragRef.value.removeEventListener("dragover");
dragRef.value.removeEventListener("drop");
}
})
</script> </script>
<template> <template>