diff --git a/src/components/ImagePreview/index.vue b/src/components/ImagePreview/index.vue index cd6a157..26380bb 100644 --- a/src/components/ImagePreview/index.vue +++ b/src/components/ImagePreview/index.vue @@ -20,7 +20,7 @@ import { isExternal } from "@/utils/validate"; const props = defineProps({ src: { type: String, - required: true + default: "" }, width: { type: [Number, String], @@ -33,6 +33,9 @@ const props = defineProps({ }); const realSrc = computed(() => { + if (!props.src) { + return; + } let real_src = props.src.split(",")[0]; if (isExternal(real_src)) { return real_src; @@ -41,6 +44,9 @@ const realSrc = computed(() => { }); const realSrcList = computed(() => { + if (!props.src) { + return; + } let real_src_list = props.src.split(","); let srcList = []; real_src_list.forEach(item => {