Kaynağa Gözat

Merge pull request #1606 from Leopoldthecoder/dev

Select: fix display issue of object-typed value in remote mode
baiyaaaaa 8 yıl önce
ebeveyn
işleme
87f952745a

+ 1 - 0
packages/select/src/option.vue

@@ -121,6 +121,7 @@
 
     created() {
       this.parent.options.push(this);
+      if (this.parent.remote) this.parent.cachedOptions.push(this);
       this.parent.optionsCount++;
       this.parent.filteredOptionsCount++;
       this.index = this.parent.options.indexOf(this);

+ 3 - 1
packages/select/src/select.vue

@@ -183,6 +183,7 @@
     data() {
       return {
         options: [],
+        cachedOptions: [],
         selected: this.multiple ? [] : {},
         isSelect: true,
         inputLength: 20,
@@ -337,7 +338,8 @@
       },
 
       getOption(value) {
-        const option = this.options.filter(option => option.value === value)[0];
+        const option = (this.remote ? this.cachedOptions : this.options)
+          .filter(option => option.value === value)[0];
         if (option) return option;
         const label = typeof value === 'string' || typeof value === 'number'
           ? value : '';