Leopoldthecoder 8 лет назад
Родитель
Сommit
7aa89a0dde
2 измененных файлов с 8 добавлено и 12 удалено
  1. 1 2
      packages/select/src/option.vue
  2. 7 10
      packages/select/src/select.vue

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

@@ -49,8 +49,7 @@
 
     computed: {
       isObject() {
-        const type = typeof this.value;
-        return type !== 'string' && type !== 'number' && type !== 'boolean';
+        return Object.prototype.toString.call(this.value).toLowerCase() === '[object object]';
       },
 
       currentLabel() {

+ 7 - 10
packages/select/src/select.vue

@@ -12,7 +12,7 @@
         <el-tag
           v-for="item in selected"
           :key="getValueKey(item)"
-          closable
+          :closable="!disabled"
           :hit="item.hitState"
           type="primary"
           @close="deleteTag($event, item)"
@@ -355,22 +355,20 @@
       },
 
       scrollToOption(option) {
-        if (this.$refs.popper && option) {
+        const target = Array.isArray(option) && option[0] ? option[0].$el : option.$el;
+        if (this.$refs.popper && target) {
           const menu = this.$refs.popper.$el.querySelector('.el-select-dropdown__wrap');
-          scrollIntoView(menu, option.$el);
+          scrollIntoView(menu, target);
         }
       },
 
       handleMenuEnter() {
-        if (!this.multiple) {
-          this.$nextTick(() => this.scrollToOption(this.selected));
-        }
+        this.$nextTick(() => this.scrollToOption(this.selected));
       },
 
       getOption(value) {
         let option;
-        const type = typeof value;
-        const isObject = type !== 'string' && type !== 'number' && type !== 'boolean';
+        const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
         for (let i = this.cachedOptions.length - 1; i >= 0; i--) {
           const cachedOption = this.cachedOptions[i];
           const isEqual = isObject
@@ -532,8 +530,7 @@
       },
 
       getValueIndex(arr = [], value) {
-        const type = typeof value;
-        const isObject = type !== 'string' && type !== 'number' && type !== 'boolean';
+        const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
         if (!isObject) {
           return arr.indexOf(value);
         } else {