Commit c70ff0f294813abb05d1caaf8aa4b3dd395ed455
1 parent
78d8ea4d
fixed #915
Showing
2 changed files
with
11 additions
and
7 deletions
Show diff stats
examples/routers/select.vue
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | <Row> | 2 | <Row> |
| 3 | <i-col span="4">{{model}}</i-col> | 3 | <i-col span="4">{{model}}</i-col> |
| 4 | <i-col span="8"> | 4 | <i-col span="8"> |
| 5 | - <i-select v-model="model" @input="handleInput" multiple filterable remote :remote-method="remoteMethod" :loading="loading" clearable> | 5 | + <i-select v-model="model" @input="handleInput" filterable remote :remote-method="remoteMethod" :loading="loading" clearable> |
| 6 | <i-option v-for="option in options" :value="option.value" :key="new Date()">{{option.label}}</i-option> | 6 | <i-option v-for="option in options" :value="option.value" :key="new Date()">{{option.label}}</i-option> |
| 7 | </i-select> | 7 | </i-select> |
| 8 | </i-col> | 8 | </i-col> |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | export default { | 13 | export default { |
| 14 | data () { | 14 | data () { |
| 15 | return { | 15 | return { |
| 16 | - model: [], | 16 | + model: '', |
| 17 | options: [ | 17 | options: [ |
| 18 | 18 | ||
| 19 | ], | 19 | ], |
| @@ -93,7 +93,10 @@ | @@ -93,7 +93,10 @@ | ||
| 93 | }, | 93 | }, |
| 94 | mounted () { | 94 | mounted () { |
| 95 | this.list = this.states.map(item => { | 95 | this.list = this.states.map(item => { |
| 96 | - return { value: item, label: item }; | 96 | + return { |
| 97 | + value: item, | ||
| 98 | + label: 'L ' + item | ||
| 99 | + }; | ||
| 97 | }); | 100 | }); |
| 98 | } | 101 | } |
| 99 | } | 102 | } |
src/components/select/select.vue
| @@ -118,6 +118,7 @@ | @@ -118,6 +118,7 @@ | ||
| 118 | selectedMultiple: [], | 118 | selectedMultiple: [], |
| 119 | focusIndex: 0, | 119 | focusIndex: 0, |
| 120 | query: '', | 120 | query: '', |
| 121 | + lastQuery: '', | ||
| 121 | selectToChangeQuery: false, // when select an option, set this first and set query, because query is watching, it will emit event | 122 | selectToChangeQuery: false, // when select an option, set this first and set query, because query is watching, it will emit event |
| 122 | inputLength: 20, | 123 | inputLength: 20, |
| 123 | notFound: false, | 124 | notFound: false, |
| @@ -528,10 +529,10 @@ | @@ -528,10 +529,10 @@ | ||
| 528 | this.query = child.label === undefined ? child.searchLabel : child.label; | 529 | this.query = child.label === undefined ? child.searchLabel : child.label; |
| 529 | } | 530 | } |
| 530 | }); | 531 | }); |
| 531 | - // 如果删除了搜索词,下拉列表也情况了,所以强制调用一次remoteMethod | ||
| 532 | - if (this.remote) { | 532 | + // 如果删除了搜索词,下拉列表也清空了,所以强制调用一次remoteMethod |
| 533 | + if (this.remote && this.query !== this.lastQuery) { | ||
| 533 | this.$nextTick(() => { | 534 | this.$nextTick(() => { |
| 534 | - this.query = model; | 535 | + this.query = this.lastQuery; |
| 535 | }); | 536 | }); |
| 536 | } | 537 | } |
| 537 | } else { | 538 | } else { |
| @@ -645,7 +646,7 @@ | @@ -645,7 +646,7 @@ | ||
| 645 | this.findChild((child) => { | 646 | this.findChild((child) => { |
| 646 | if (child.value === value) { | 647 | if (child.value === value) { |
| 647 | if (this.query !== '') this.selectToChangeQuery = true; | 648 | if (this.query !== '') this.selectToChangeQuery = true; |
| 648 | - this.query = child.label === undefined ? child.searchLabel : child.label; | 649 | + this.lastQuery = this.query = child.label === undefined ? child.searchLabel : child.label; |
| 649 | } | 650 | } |
| 650 | }); | 651 | }); |
| 651 | } | 652 | } |