Commit 9c3a3e7d03404d4ac5c7c26040e4d5e78de88022
Committed by
GitHub
1 parent
d33b339a
更新 Select 组件
select组件如果有filterable属性,对model进行修改,选择框为空值。
Showing
1 changed file
with
17 additions
and
13 deletions
Show diff stats
src/components/select/select.vue
... | ... | @@ -478,22 +478,25 @@ |
478 | 478 | setQuery (query) { |
479 | 479 | if (!this.filterable) return; |
480 | 480 | this.query = query; |
481 | + }, | |
482 | + modelToQuery() { | |
483 | + if (!this.multiple && this.filterable && this.model) { | |
484 | + this.findChild((child) => { | |
485 | + if (this.model === child.value) { | |
486 | + if (child.label) { | |
487 | + this.query = child.label; | |
488 | + } else if (child.searchLabel) { | |
489 | + this.query = child.searchLabel; | |
490 | + } else { | |
491 | + this.query = child.value; | |
492 | + } | |
493 | + } | |
494 | + }); | |
495 | + } | |
481 | 496 | } |
482 | 497 | }, |
483 | 498 | compiled () { |
484 | - if (!this.multiple && this.filterable && this.model) { | |
485 | - this.findChild((child) => { | |
486 | - if (this.model === child.value) { | |
487 | - if (child.label) { | |
488 | - this.query = child.label; | |
489 | - } else if (child.searchLabel) { | |
490 | - this.query = child.searchLabel; | |
491 | - } else { | |
492 | - this.query = child.value; | |
493 | - } | |
494 | - } | |
495 | - }); | |
496 | - } | |
499 | + this.modelToQuery() | |
497 | 500 | |
498 | 501 | this.updateOptions(true); |
499 | 502 | document.addEventListener('keydown', this.handleKeydown); |
... | ... | @@ -521,6 +524,7 @@ |
521 | 524 | }, |
522 | 525 | watch: { |
523 | 526 | model () { |
527 | + this.modelToQuery() | |
524 | 528 | if (this.multiple) { |
525 | 529 | if (this.slotChangeDuration) { |
526 | 530 | this.slotChangeDuration = false; | ... | ... |