Commit e2006187555d81bb86440e2c05d3d33a812ca1a8
1 parent
7c4c9d9c
fixed #159
fixed #159
Showing
2 changed files
with
17 additions
and
10 deletions
Show diff stats
src/components/select/select.vue
| ... | ... | @@ -466,6 +466,20 @@ |
| 466 | 466 | } |
| 467 | 467 | }, |
| 468 | 468 | ready () { |
| 469 | + if (!this.multiple && this.filterable && this.model) { | |
| 470 | + this.findChild((child) => { | |
| 471 | + if (this.model === child.value) { | |
| 472 | + if (child.label) { | |
| 473 | + this.query = child.label; | |
| 474 | + } else if (child.searchLabel) { | |
| 475 | + this.query = child.searchLabel; | |
| 476 | + } else { | |
| 477 | + this.query = child.value; | |
| 478 | + } | |
| 479 | + } | |
| 480 | + }); | |
| 481 | + } | |
| 482 | + | |
| 469 | 483 | this.updateOptions(true); |
| 470 | 484 | document.addEventListener('keydown', this.handleKeydown); |
| 471 | 485 | ... | ... |
test/routers/select.vue
| 1 | 1 | <template> |
| 2 | - <i-button @click="clear">clear</i-button> | |
| 3 | 2 | <Row> |
| 4 | 3 | <i-col span="12" style="padding-right:10px"> |
| 5 | - <i-select :model.sync="model11" filterable v-ref:select clearable> | |
| 4 | + <i-select :model.sync="model11" filterable> | |
| 6 | 5 | <i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option> |
| 7 | 6 | </i-select> |
| 8 | 7 | </i-col> |
| ... | ... | @@ -43,14 +42,8 @@ |
| 43 | 42 | label: '重庆市' |
| 44 | 43 | } |
| 45 | 44 | ], |
| 46 | - model11: '', | |
| 47 | - model12: [] | |
| 48 | - } | |
| 49 | - }, | |
| 50 | - methods: { | |
| 51 | - clear () { | |
| 52 | -// this.$refs.select.setQuery(''); | |
| 53 | - this.$refs.select.clearSingleSelect(); | |
| 45 | + model11: 'beijing', | |
| 46 | + model12: ['beijing', 'shanghai'] | |
| 54 | 47 | } |
| 55 | 48 | } |
| 56 | 49 | } | ... | ... |