diff --git a/packages/select/src/select.vue b/packages/select/src/select.vue index fc16266d4..09f59b057 100644 --- a/packages/select/src/select.vue +++ b/packages/select/src/select.vue @@ -660,8 +660,7 @@ }, getValueKey(item) { - const type = typeof item.value; - if (type === 'number' || type === 'string') { + if (Object.prototype.toString.call(item.value).toLowerCase() !== '[object object]') { return item.value; } else { return getValueByPath(item.value, this.valueKey); @@ -677,7 +676,6 @@ if (!this.multiple && Array.isArray(this.value)) { this.$emit('input', ''); } - this.setSelected(); this.debouncedOnInputChange = debounce(this.debounce, () => { this.onInputChange(); @@ -701,6 +699,7 @@ this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width; } }); + this.setSelected(); }, beforeDestroy() { diff --git a/test/unit/specs/select.spec.js b/test/unit/specs/select.spec.js index 3464a943d..9400c7cdc 100644 --- a/test/unit/specs/select.spec.js +++ b/test/unit/specs/select.spec.js @@ -585,20 +585,22 @@ describe('Select', () => { } } }, true); - const tagCloseIcons = vm.$el.querySelectorAll('.el-tag__close'); expect(vm.value.length).to.equal(2); - tagCloseIcons[1].click(); setTimeout(() => { - expect(vm.value.length).to.equal(1); - expect(window.console.log.callCount).to.equal(1); - tagCloseIcons[0].click(); + const tagCloseIcons = vm.$el.querySelectorAll('.el-tag__close'); + tagCloseIcons[1].click(); setTimeout(() => { - expect(vm.value.length).to.equal(0); - expect(window.console.log.callCount).to.equal(2); - window.console.log.restore(); - done(); - }, 100); - }, 100); + expect(vm.value.length).to.equal(1); + expect(window.console.log.callCount).to.equal(1); + tagCloseIcons[0].click(); + setTimeout(() => { + expect(vm.value.length).to.equal(0); + expect(window.console.log.callCount).to.equal(2); + window.console.log.restore(); + done(); + }, 50); + }, 50); + }, 50); }); it('multiple limit', done => {