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