Browse Source

Upload: use uid as upload-list key (#13054)

* Upload: use uid as upload-list key

* chore: fix code style
hetech 6 years ago
parent
commit
0de8a032c0
2 changed files with 9 additions and 7 deletions
  1. 4 5
      packages/form/src/form.vue
  2. 5 2
      packages/upload/src/upload-list.vue

+ 4 - 5
packages/form/src/form.vue

@@ -85,11 +85,10 @@
       },
       clearValidate(props = []) {
         const fields = props.length
-          ? (typeof props === 'string' 
-              ? this.fields.filter(field => props === field.prop)
-              : this.fields.filter(field => props.indexOf(field.prop) > -1)
-            )
-          : this.fields;
+          ? (typeof props === 'string'
+            ? this.fields.filter(field => props === field.prop)
+            : this.fields.filter(field => props.indexOf(field.prop) > -1)
+          ) : this.fields;
         fields.forEach(field => {
           field.clearValidate();
         });

+ 5 - 2
packages/upload/src/upload-list.vue

@@ -9,9 +9,9 @@
     name="el-list"
   >
     <li
-      v-for="(file, index) in files"
+      v-for="file in files"
       :class="['el-upload-list__item', 'is-' + file.status, focusing ? 'focusing' : '']"
-      :key="index"
+      :key="file.uid"
       tabindex="0"
       @keydown.delete="!disabled && $emit('remove', file)"
       @focus="focusing = true"
@@ -65,6 +65,9 @@
   import ElProgress from 'element-ui/packages/progress';
 
   export default {
+
+    name: 'ElUploadList',
+
     mixins: [Locale],
 
     data() {