Commit f789787fd69e33f700bf7109f0e924a4db06b7d6

Authored by YikaJ
Committed by GitHub
2 parents d33b339a 9c3a3e7d

Merge pull request #1 from YikaJ/YikaJ-select-fixed

更新 Select 组件
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;
... ...