Commit c70ff0f294813abb05d1caaf8aa4b3dd395ed455

Authored by 梁灏
1 parent 78d8ea4d

fixed #915

examples/routers/select.vue
... ... @@ -2,7 +2,7 @@
2 2 <Row>
3 3 <i-col span="4">{{model}}</i-col>
4 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 6 <i-option v-for="option in options" :value="option.value" :key="new Date()">{{option.label}}</i-option>
7 7 </i-select>
8 8 </i-col>
... ... @@ -13,7 +13,7 @@
13 13 export default {
14 14 data () {
15 15 return {
16   - model: [],
  16 + model: '',
17 17 options: [
18 18  
19 19 ],
... ... @@ -93,7 +93,10 @@
93 93 },
94 94 mounted () {
95 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 118 selectedMultiple: [],
119 119 focusIndex: 0,
120 120 query: '',
  121 + lastQuery: '',
121 122 selectToChangeQuery: false, // when select an option, set this first and set query, because query is watching, it will emit event
122 123 inputLength: 20,
123 124 notFound: false,
... ... @@ -528,10 +529,10 @@
528 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 534 this.$nextTick(() => {
534   - this.query = model;
  535 + this.query = this.lastQuery;
535 536 });
536 537 }
537 538 } else {
... ... @@ -645,7 +646,7 @@
645 646 this.findChild((child) => {
646 647 if (child.value === value) {
647 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 }
... ...