Commit ec98f3c3aed842a48c1abe83c9e338cbb6923a31

Authored by 梁灏
1 parent 01b54e30

update Select

examples/routers/select.vue
1 1 <template>
2 2 <div style="width: 200px;margin: 100px;">
  3 + {{ model }}
3 4 <i-select v-model="model" filterable remote :remote-method="remoteMethod" :loading="loading" clearable style="width:200px">
4 5 <i-option v-for="option in options" :value="option.value" :key="option">{{option.label}}</i-option>
5 6 </i-select>
... ... @@ -80,7 +81,7 @@
80 81 return item.label.toLowerCase()
81 82 .indexOf(query.toLowerCase()) > -1;
82 83 });
83   - }, 200);
  84 + }, 500);
84 85 } else {
85 86 this.options = [];
86 87 }
... ...
src/components/select/select.vue
... ... @@ -25,10 +25,7 @@
25 25 <Icon type="arrow-down-b" :class="[prefixCls + '-arrow']" v-if="!remote"></Icon>
26 26 </div>
27 27 <transition :name="transitionName">
28   - <Drop v-show="(visible && options.length) ||
29   - (visible && !options.length && loading) ||
30   - (visible && remote && !loading && !options.length && query !== '')" :placement="placement" ref="dropdown">
31   - <!--<Drop v-show="visible" :placement="placement" ref="dropdown">-->
  28 + <Drop v-show="dropVisible" :placement="placement" ref="dropdown">
32 29 <ul v-show="(notFound && !remote) || (remote && !loading && !options.length)" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul>
33 30 <ul v-show="(!notFound && !remote) || (remote && !loading && !notFound)" :class="[prefixCls + '-dropdown-list']" ref="options"><slot></slot></ul>
34 31 <ul v-show="loading" :class="[prefixCls + '-loading']">{{ localeLoadingText }}</ul>
... ... @@ -196,6 +193,11 @@
196 193 },
197 194 transitionName () {
198 195 return this.placement === 'bottom' ? 'slide-up' : 'slide-down';
  196 + },
  197 + dropVisible () {
  198 + let status = true;
  199 + if (!this.loading && this.remote && this.query === '' && !this.options.length) status = false;
  200 + return this.visible && status;
199 201 }
200 202 },
201 203 methods: {
... ... @@ -203,7 +205,6 @@
203 205 if (this.disabled) {
204 206 return false;
205 207 }
206   -
207 208 this.visible = !this.visible;
208 209 },
209 210 hideMenu () {
... ... @@ -224,7 +225,7 @@
224 225 child.$children.forEach((innerChild) => {
225 226 find(innerChild, cb);
226 227 });
227   - })
  228 + });
228 229 }
229 230 };
230 231  
... ...