From e9ca735d81e81370a594fc7c6b3156d85027a508 Mon Sep 17 00:00:00 2001 From: Warsono Date: Tue, 2 Nov 2021 13:55:28 +0700 Subject: [PATCH] feat(v-file-upload): allow string as initial value --- src/components/VFileUpload/VFileUpload.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/VFileUpload/VFileUpload.vue b/src/components/VFileUpload/VFileUpload.vue index 9da1bb768..6683753c1 100644 --- a/src/components/VFileUpload/VFileUpload.vue +++ b/src/components/VFileUpload/VFileUpload.vue @@ -20,7 +20,7 @@ import VInput from '../VInput/VInput.vue'; import {ErrorMessage} from 'vee-validate'; import {AnyMessageParams} from 'yup/lib/types'; -type FileValue = File | FileList | File[] | Record | null; +type FileValue = File | FileList | File[] | Record | string | null; const props = defineProps({ value: { @@ -228,6 +228,11 @@ const setInitialValue = (val: any) => { const isFile = val instanceof File; const isFileList = val instanceof FileList; + if (typeof val === 'string') { + hasInitialValue.value = true; + previewURL.value = val; + } + if (isFile || isFileList) { innerValue.value = val; }