Update select.vue

This commit is contained in:
YikaJ 2017-02-09 20:01:50 +08:00 committed by GitHub
parent 4e85fa156c
commit 7db4e70de2

View file

@ -480,23 +480,23 @@
this.query = query; this.query = query;
}, },
modelToQuery() { modelToQuery() {
if (!this.multiple && this.filterable && this.model) { if (!this.multiple && this.filterable && this.model) {
this.findChild((child) => { this.findChild((child) => {
if (this.model === child.value) { if (this.model === child.value) {
if (child.label) { if (child.label) {
this.query = child.label; this.query = child.label;
} else if (child.searchLabel) { } else if (child.searchLabel) {
this.query = child.searchLabel; this.query = child.searchLabel;
} else { } else {
this.query = child.value; this.query = child.value;
} }
} }
}); });
} }
} }
}, },
compiled () { compiled () {
this.modelToQuery() this.modelToQuery();
this.updateOptions(true); this.updateOptions(true);
document.addEventListener('keydown', this.handleKeydown); document.addEventListener('keydown', this.handleKeydown);
@ -504,6 +504,7 @@
// watch slot changed // watch slot changed
if (MutationObserver) { if (MutationObserver) {
this.observer = new MutationObserver(() => { this.observer = new MutationObserver(() => {
this.modelToQuery();
this.slotChange(); this.slotChange();
this.updateOptions(true, true); this.updateOptions(true, true);
}); });
@ -524,7 +525,7 @@
}, },
watch: { watch: {
model () { model () {
this.modelToQuery() this.modelToQuery();
if (this.multiple) { if (this.multiple) {
if (this.slotChangeDuration) { if (this.slotChangeDuration) {
this.slotChangeDuration = false; this.slotChangeDuration = false;