From 6cfe46c60b2f9af4af0c1f2bfe254ee7a3b25998 Mon Sep 17 00:00:00 2001 From: sakuya <81883387@qq.com> Date: Wed, 19 May 2021 00:40:31 +0800 Subject: [PATCH] UP --- src/components/scUpload/multiple.vue | 50 +++++++++++++++------------- src/views/vab/upload.vue | 2 +- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/components/scUpload/multiple.vue b/src/components/scUpload/multiple.vue index 265138e5..9c860194 100644 --- a/src/components/scUpload/multiple.vue +++ b/src/components/scUpload/multiple.vue @@ -8,7 +8,7 @@
- +
@@ -17,7 +17,7 @@
- + 点击上传
@@ -33,35 +33,39 @@ }, data(){ return { + defaultList: this.toArr(this.modelValue), fileList: [] } }, watch:{ - // modelValue(){ - // this.fileList = this.toArr(this.modelValue); - // }, - // fileList: { - // handler(){ - // this.$emit('update:modelValue', this.toStr(this.fileList)); - // }, - // deep: true - // } + modelValue(){ + + }, + fileList: { + handler(val){ + this.$emit('update:modelValue', this.toStr(val)); + }, + deep: true + } }, mounted() { - this.fileList = this.toArr(this.modelValue); - this.$refs.upload.uploadFiles = this.fileList + this.fileList = this.$refs.upload.uploadFiles + }, methods: { + //默认值转换为数组 toArr(str){ var _arr = []; var arr = str.split(","); arr.forEach(item => { - _arr.push({ - name: "F", - status: "success", - url: item - }) + if(item){ + _arr.push({ + name: "F", + status: "success", + url: item + }) + } }) return _arr; }, @@ -75,15 +79,13 @@ return str; }, before(){ - this.fileList = this.$refs.upload.uploadFiles; - this.fileList.forEach(item => { - if(item.status!='success'){ - item.tempURL = URL.createObjectURL(item.raw); - } - }) + console.log(this.$refs.upload.uploadFiles); }, success(res, file){ file.url = res.data.src + }, + remove(){ + }, error(err){ this.$notify.error({ diff --git a/src/views/vab/upload.vue b/src/views/vab/upload.vue index 88391013..e9ed0d04 100644 --- a/src/views/vab/upload.vue +++ b/src/views/vab/upload.vue @@ -52,7 +52,7 @@ uploadUrl: this.$API.demo.upload.url, imgurl: "images/avatar.jpg", avatar: "", - imgs: "images/avatar.jpg,images/avatar.jpg", + imgs: "images/avatar.jpg,images/avatar2.gif,images/avatar3.gif", form: { img1: "", img2: "",