From c3e8b77d47752b3f2b147462f3755b25311b5f77 Mon Sep 17 00:00:00 2001 From: HarlanLuo Date: Mon, 17 Dec 2018 10:30:13 +0800 Subject: [PATCH] Upload: add url prop to upload file when list-type changed (#13771) --- packages/upload/src/index.vue | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/upload/src/index.vue b/packages/upload/src/index.vue index e050524b..32f27563 100644 --- a/packages/upload/src/index.vue +++ b/packages/upload/src/index.vue @@ -122,6 +122,20 @@ export default { }, watch: { + listType(type) { + if (type === 'picture-card' || type === 'picture') { + this.uploadFiles.forEach(file => { + if (!file.url && file.raw) { + try { + file.url = URL.createObjectURL(file.raw); + } catch (err) { + console.error('[Element Error][Upload]', err); + return; + } + } + }); + } + }, fileList: { immediate: true, handler(fileList) {