mirror of https://github.com/ElemeFE/element
Select: move setSelect to mounted hook
parent
a750f5d6b1
commit
36d4f0a6fc
|
@ -660,8 +660,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
getValueKey(item) {
|
getValueKey(item) {
|
||||||
const type = typeof item.value;
|
if (Object.prototype.toString.call(item.value).toLowerCase() !== '[object object]') {
|
||||||
if (type === 'number' || type === 'string') {
|
|
||||||
return item.value;
|
return item.value;
|
||||||
} else {
|
} else {
|
||||||
return getValueByPath(item.value, this.valueKey);
|
return getValueByPath(item.value, this.valueKey);
|
||||||
|
@ -677,7 +676,6 @@
|
||||||
if (!this.multiple && Array.isArray(this.value)) {
|
if (!this.multiple && Array.isArray(this.value)) {
|
||||||
this.$emit('input', '');
|
this.$emit('input', '');
|
||||||
}
|
}
|
||||||
this.setSelected();
|
|
||||||
|
|
||||||
this.debouncedOnInputChange = debounce(this.debounce, () => {
|
this.debouncedOnInputChange = debounce(this.debounce, () => {
|
||||||
this.onInputChange();
|
this.onInputChange();
|
||||||
|
@ -701,6 +699,7 @@
|
||||||
this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width;
|
this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.setSelected();
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
|
|
@ -585,20 +585,22 @@ describe('Select', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
const tagCloseIcons = vm.$el.querySelectorAll('.el-tag__close');
|
|
||||||
expect(vm.value.length).to.equal(2);
|
expect(vm.value.length).to.equal(2);
|
||||||
tagCloseIcons[1].click();
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(vm.value.length).to.equal(1);
|
const tagCloseIcons = vm.$el.querySelectorAll('.el-tag__close');
|
||||||
expect(window.console.log.callCount).to.equal(1);
|
tagCloseIcons[1].click();
|
||||||
tagCloseIcons[0].click();
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(vm.value.length).to.equal(0);
|
expect(vm.value.length).to.equal(1);
|
||||||
expect(window.console.log.callCount).to.equal(2);
|
expect(window.console.log.callCount).to.equal(1);
|
||||||
window.console.log.restore();
|
tagCloseIcons[0].click();
|
||||||
done();
|
setTimeout(() => {
|
||||||
}, 100);
|
expect(vm.value.length).to.equal(0);
|
||||||
}, 100);
|
expect(window.console.log.callCount).to.equal(2);
|
||||||
|
window.console.log.restore();
|
||||||
|
done();
|
||||||
|
}, 50);
|
||||||
|
}, 50);
|
||||||
|
}, 50);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('multiple limit', done => {
|
it('multiple limit', done => {
|
||||||
|
|
Loading…
Reference in New Issue