update Select

This commit is contained in:
梁灏 2017-05-09 11:04:07 +08:00
parent 7dcfe45d1b
commit 13a940ee86

View file

@ -196,7 +196,8 @@
}, },
dropVisible () { dropVisible () {
let status = true; let status = true;
if (!this.loading && this.remote && this.query === '' && !this.options.length) status = false; const options = this.$slots.default || [];
if (!this.loading && this.remote && this.query === '' && !options.length) status = false;
return this.visible && status; return this.visible && status;
} }
}, },
@ -214,18 +215,12 @@
}, },
// find option component // find option component
findChild (cb) { findChild (cb) {
const _this = this;
const find = function (child) { const find = function (child) {
const name = child.$options.componentName; const name = child.$options.componentName;
if (name) { if (name) {
cb(child); cb(child);
} else if (child.$children.length) { } else if (child.$children.length) {
_this.$nextTick(() => {
// child.$children.forEach((innerChild) => {
// find(innerChild, cb);
// });
});
child.$children.forEach((innerChild) => { child.$children.forEach((innerChild) => {
find(innerChild, cb); find(innerChild, cb);
}); });
@ -599,7 +594,7 @@
}); });
} else { } else {
this.findChild(child => { this.findChild(child => {
child.selected = this.model.indexOf(child.value) > -1; child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
}); });
} }
this.slotChange(); this.slotChange();
@ -613,7 +608,7 @@
}); });
} else { } else {
this.findChild(child => { this.findChild(child => {
child.selected = this.model.indexOf(child.value) > -1; child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
}); });
} }
this.slotChange(); this.slotChange();
@ -685,7 +680,7 @@
} }
if (this.remote) { if (this.remote) {
this.findChild(child => { this.findChild(child => {
child.selected = this.model.indexOf(child.value) > -1; child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
}); });
} }
} }