Browse Source

fix: picker listData异步更新问题 #355

richard1015 5 years ago
parent
commit
14111b1f64
1 changed files with 12 additions and 12 deletions
  1. 12 12
      src/packages/picker/picker.vue

+ 12 - 12
src/packages/picker/picker.vue

@@ -92,25 +92,25 @@ export default {
       this.chooseValueData = [...this.cacheValueData];
       this.$emit('close');
     },
-
     chooseItem(value, index) {
       if (this.cacheValueData[index] !== value) {
         this.cacheValueData[index] = value;
         this.$emit('choose', this, index, value, this.cacheValueData);
       }
+    },
+    init() {
+      if (this.defaultValueData && this.defaultValueData.length) {
+        this.chooseValueData = [...this.defaultValueData];
+      } else {
+        let defaultValueData = [];
+        this.listData.map((item, index) => {
+          defaultValueData.push(item[0]);
+        });
+        this.chooseValueData = [...defaultValueData];
+      }
     }
   },
-  init() {
-    if (this.defaultValueData && this.defaultValueData.length) {
-      this.chooseValueData = [...this.defaultValueData];
-    } else {
-      let defaultValueData = [];
-      this.listData.map((item, index) => {
-        defaultValueData.push(item[0]);
-      });
-      this.chooseValueData = [...defaultValueData];
-    }
-  },
+
   created() {
     this.init();
   }