Procházet zdrojové kódy

图片预览显示问题

zhulu před 2 roky
rodič
revize
b1843faeb8

+ 3 - 0
src/components/ImageListPreview/index.vue

@@ -39,6 +39,7 @@ export default {
   data() {
     return {
       fileList: [],
+      previewSrcList:[]
     }
   },
   watch: {
@@ -48,10 +49,12 @@ export default {
         if(newVal){
         const list = Array.isArray(newVal) ? newVal : this.value.split(",");
         this.fileList = list.map((url) => ({ name: url, url }));
+        this.previewSrcList=list.map((url) => url);
         console.log("this.fileList",this.fileList);
       }        
         else{
           this.fileList =[];
+          this.previewSrcList=[];
         }
       },
     },

+ 5 - 0
src/components/K-FileUpload/index.vue

@@ -100,6 +100,11 @@ export default {
           // 首先将值转为数组
           const list = Array.isArray(val) ? val : this.value.split(',');
           console.log("watch fileList", list)
+          if(list.length>this.limit)
+          {
+            this.handleExceed();
+            return;
+          }
           // 然后将数组转为对象数组
           this.fileList = list.map(item => {
             if (typeof item === "string") {