瀏覽代碼

fix multiple remote select's default value issue

Leopoldthecoder 8 年之前
父節點
當前提交
5352f31f16
共有 2 個文件被更改,包括 9 次插入0 次删除
  1. 1 0
      CHANGELOG.md
  2. 8 0
      packages/select/src/select.vue

+ 1 - 0
CHANGELOG.md

@@ -13,6 +13,7 @@
 - 修复 DatePicker 弹出框样式溢出边框 #318
 - 新增 Input 图标的点击事件 #444
 - 修复 Loading 关闭后有几率滚动失效的问题
+- 修复 远程搜索的 Select 不能正确渲染默认初始值的问题
 
 #### 非兼容性更新
 

+ 8 - 0
packages/select/src/select.vue

@@ -528,6 +528,14 @@
     },
 
     mounted() {
+      if (this.remote && this.multiple && Array.isArray(this.value)) {
+        this.selected = this.options.reduce((prev, curr) => {
+          return this.value.indexOf(curr.value) > -1 ? prev.concat(curr) : prev;
+        }, []);
+        this.$nextTick(() => {
+          this.resetInputHeight();
+        });
+      }
       this.$nextTick(() => {
         if (this.$refs.reference.$el) {
           this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width;