Commit 13a940ee8665eb5c0cb7cf856460a26d924c8015
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 | 196 | }, |
| 197 | 197 | dropVisible () { |
| 198 | 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 | 201 | return this.visible && status; |
| 201 | 202 | } |
| 202 | 203 | }, |
| ... | ... | @@ -214,18 +215,12 @@ |
| 214 | 215 | }, |
| 215 | 216 | // find option component |
| 216 | 217 | findChild (cb) { |
| 217 | - const _this = this; | |
| 218 | 218 | const find = function (child) { |
| 219 | 219 | const name = child.$options.componentName; |
| 220 | 220 | |
| 221 | 221 | if (name) { |
| 222 | 222 | cb(child); |
| 223 | 223 | } else if (child.$children.length) { |
| 224 | - _this.$nextTick(() => { | |
| 225 | -// child.$children.forEach((innerChild) => { | |
| 226 | -// find(innerChild, cb); | |
| 227 | -// }); | |
| 228 | - }); | |
| 229 | 224 | child.$children.forEach((innerChild) => { |
| 230 | 225 | find(innerChild, cb); |
| 231 | 226 | }); |
| ... | ... | @@ -599,7 +594,7 @@ |
| 599 | 594 | }); |
| 600 | 595 | } else { |
| 601 | 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 | 600 | this.slotChange(); |
| ... | ... | @@ -613,7 +608,7 @@ |
| 613 | 608 | }); |
| 614 | 609 | } else { |
| 615 | 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 | 614 | this.slotChange(); |
| ... | ... | @@ -685,7 +680,7 @@ |
| 685 | 680 | } |
| 686 | 681 | if (this.remote) { |
| 687 | 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 | } | ... | ... |