Commit 13a940ee8665eb5c0cb7cf856460a26d924c8015

Authored by 梁灏
1 parent 7dcfe45d

update Select

Showing 1 changed file with 5 additions and 10 deletions   Show diff stats
src/components/select/select.vue
@@ -196,7 +196,8 @@ @@ -196,7 +196,8 @@
196 }, 196 },
197 dropVisible () { 197 dropVisible () {
198 let status = true; 198 let status = true;
199 - if (!this.loading && this.remote && this.query === '' && !this.options.length) status = false; 199 + const options = this.$slots.default || [];
  200 + if (!this.loading && this.remote && this.query === '' && !options.length) status = false;
200 return this.visible && status; 201 return this.visible && status;
201 } 202 }
202 }, 203 },
@@ -214,18 +215,12 @@ @@ -214,18 +215,12 @@
214 }, 215 },
215 // find option component 216 // find option component
216 findChild (cb) { 217 findChild (cb) {
217 - const _this = this;  
218 const find = function (child) { 218 const find = function (child) {
219 const name = child.$options.componentName; 219 const name = child.$options.componentName;
220 220
221 if (name) { 221 if (name) {
222 cb(child); 222 cb(child);
223 } else if (child.$children.length) { 223 } else if (child.$children.length) {
224 - _this.$nextTick(() => {  
225 -// child.$children.forEach((innerChild) => {  
226 -// find(innerChild, cb);  
227 -// });  
228 - });  
229 child.$children.forEach((innerChild) => { 224 child.$children.forEach((innerChild) => {
230 find(innerChild, cb); 225 find(innerChild, cb);
231 }); 226 });
@@ -599,7 +594,7 @@ @@ -599,7 +594,7 @@
599 }); 594 });
600 } else { 595 } else {
601 this.findChild(child => { 596 this.findChild(child => {
602 - child.selected = this.model.indexOf(child.value) > -1; 597 + child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
603 }); 598 });
604 } 599 }
605 this.slotChange(); 600 this.slotChange();
@@ -613,7 +608,7 @@ @@ -613,7 +608,7 @@
613 }); 608 });
614 } else { 609 } else {
615 this.findChild(child => { 610 this.findChild(child => {
616 - child.selected = this.model.indexOf(child.value) > -1; 611 + child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
617 }); 612 });
618 } 613 }
619 this.slotChange(); 614 this.slotChange();
@@ -685,7 +680,7 @@ @@ -685,7 +680,7 @@
685 } 680 }
686 if (this.remote) { 681 if (this.remote) {
687 this.findChild(child => { 682 this.findChild(child => {
688 - child.selected = this.model.indexOf(child.value) > -1; 683 + child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
689 }); 684 });
690 } 685 }
691 } 686 }