mirror of https://github.com/ElemeFE/element
commit
9773276fee
|
@ -88,10 +88,10 @@
|
|||
|
||||
watch: {
|
||||
currentLabel() {
|
||||
this.dispatch('ElSelect', 'setSelected');
|
||||
if (!this.created) this.dispatch('ElSelect', 'setSelected');
|
||||
},
|
||||
value() {
|
||||
this.dispatch('ElSelect', 'setSelected');
|
||||
if (!this.created) this.dispatch('ElSelect', 'setSelected');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
import { addClass, removeClass, hasClass } from 'element-ui/src/utils/dom';
|
||||
import { addResizeListener, removeResizeListener } from 'element-ui/src/utils/resize-event';
|
||||
import { t } from 'element-ui/src/locale';
|
||||
import merge from 'element-ui/src/utils/merge';
|
||||
const sizeMap = {
|
||||
'large': 42,
|
||||
'small': 30,
|
||||
|
@ -191,6 +192,8 @@
|
|||
return {
|
||||
options: [],
|
||||
cachedOptions: [],
|
||||
createdOption: null,
|
||||
createdSelected: false,
|
||||
selected: this.multiple ? [] : {},
|
||||
isSelect: true,
|
||||
inputLength: 20,
|
||||
|
@ -276,7 +279,12 @@
|
|||
if (!this.multiple) {
|
||||
this.getOverflows();
|
||||
if (this.selected) {
|
||||
this.selectedLabel = this.selected.currentLabel;
|
||||
if (this.filterable && this.allowCreate &&
|
||||
this.createdSelected && this.createdOption) {
|
||||
this.selectedLabel = this.createdOption.currentLabel;
|
||||
} else {
|
||||
this.selectedLabel = this.selected.currentLabel;
|
||||
}
|
||||
if (this.filterable) this.query = this.selectedLabel;
|
||||
}
|
||||
}
|
||||
|
@ -371,6 +379,12 @@
|
|||
setSelected() {
|
||||
if (!this.multiple) {
|
||||
let option = this.getOption(this.value);
|
||||
if (option.created) {
|
||||
this.createdOption = merge({}, option);
|
||||
this.createdSelected = true;
|
||||
} else {
|
||||
this.createdSelected = false;
|
||||
}
|
||||
this.selectedLabel = option.currentLabel;
|
||||
this.selected = option;
|
||||
return;
|
||||
|
@ -382,6 +396,9 @@
|
|||
});
|
||||
}
|
||||
this.selected = result;
|
||||
this.$nextTick(() => {
|
||||
this.resetInputHeight();
|
||||
});
|
||||
},
|
||||
|
||||
handleIconClick(event) {
|
||||
|
|
Loading…
Reference in New Issue