mirror of https://github.com/ElemeFE/element
Select: fix isObject bug
parent
d84acce8a1
commit
7aa89a0dde
|
@ -49,8 +49,7 @@
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
isObject() {
|
isObject() {
|
||||||
const type = typeof this.value;
|
return Object.prototype.toString.call(this.value).toLowerCase() === '[object object]';
|
||||||
return type !== 'string' && type !== 'number' && type !== 'boolean';
|
|
||||||
},
|
},
|
||||||
|
|
||||||
currentLabel() {
|
currentLabel() {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<el-tag
|
<el-tag
|
||||||
v-for="item in selected"
|
v-for="item in selected"
|
||||||
:key="getValueKey(item)"
|
:key="getValueKey(item)"
|
||||||
closable
|
:closable="!disabled"
|
||||||
:hit="item.hitState"
|
:hit="item.hitState"
|
||||||
type="primary"
|
type="primary"
|
||||||
@close="deleteTag($event, item)"
|
@close="deleteTag($event, item)"
|
||||||
|
@ -355,22 +355,20 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollToOption(option) {
|
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');
|
const menu = this.$refs.popper.$el.querySelector('.el-select-dropdown__wrap');
|
||||||
scrollIntoView(menu, option.$el);
|
scrollIntoView(menu, target);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleMenuEnter() {
|
handleMenuEnter() {
|
||||||
if (!this.multiple) {
|
this.$nextTick(() => this.scrollToOption(this.selected));
|
||||||
this.$nextTick(() => this.scrollToOption(this.selected));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getOption(value) {
|
getOption(value) {
|
||||||
let option;
|
let option;
|
||||||
const type = typeof value;
|
const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
|
||||||
const isObject = type !== 'string' && type !== 'number' && type !== 'boolean';
|
|
||||||
for (let i = this.cachedOptions.length - 1; i >= 0; i--) {
|
for (let i = this.cachedOptions.length - 1; i >= 0; i--) {
|
||||||
const cachedOption = this.cachedOptions[i];
|
const cachedOption = this.cachedOptions[i];
|
||||||
const isEqual = isObject
|
const isEqual = isObject
|
||||||
|
@ -532,8 +530,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
getValueIndex(arr = [], value) {
|
getValueIndex(arr = [], value) {
|
||||||
const type = typeof value;
|
const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
|
||||||
const isObject = type !== 'string' && type !== 'number' && type !== 'boolean';
|
|
||||||
if (!isObject) {
|
if (!isObject) {
|
||||||
return arr.indexOf(value);
|
return arr.indexOf(value);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue