diff --git a/packages/select/src/option.vue b/packages/select/src/option.vue index 7c381c308..9a7a6b4c1 100644 --- a/packages/select/src/option.vue +++ b/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() { diff --git a/packages/select/src/select.vue b/packages/select/src/select.vue index b9aca5e2f..fc16266d4 100644 --- a/packages/select/src/select.vue +++ b/packages/select/src/select.vue @@ -12,7 +12,7 @@ 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 {