update Select

This commit is contained in:
梁灏 2017-05-08 10:01:07 +08:00
parent 01b54e3021
commit ec98f3c3ae
2 changed files with 9 additions and 7 deletions

View file

@ -1,5 +1,6 @@
<template>
<div style="width: 200px;margin: 100px;">
{{ model }}
<i-select v-model="model" filterable remote :remote-method="remoteMethod" :loading="loading" clearable style="width:200px">
<i-option v-for="option in options" :value="option.value" :key="option">{{option.label}}</i-option>
</i-select>
@ -80,7 +81,7 @@
return item.label.toLowerCase()
.indexOf(query.toLowerCase()) > -1;
});
}, 200);
}, 500);
} else {
this.options = [];
}

View file

@ -25,10 +25,7 @@
<Icon type="arrow-down-b" :class="[prefixCls + '-arrow']" v-if="!remote"></Icon>
</div>
<transition :name="transitionName">
<Drop v-show="(visible && options.length) ||
(visible && !options.length && loading) ||
(visible && remote && !loading && !options.length && query !== '')" :placement="placement" ref="dropdown">
<!--<Drop v-show="visible" :placement="placement" ref="dropdown">-->
<Drop v-show="dropVisible" :placement="placement" ref="dropdown">
<ul v-show="(notFound && !remote) || (remote && !loading && !options.length)" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul>
<ul v-show="(!notFound && !remote) || (remote && !loading && !notFound)" :class="[prefixCls + '-dropdown-list']" ref="options"><slot></slot></ul>
<ul v-show="loading" :class="[prefixCls + '-loading']">{{ localeLoadingText }}</ul>
@ -196,6 +193,11 @@
},
transitionName () {
return this.placement === 'bottom' ? 'slide-up' : 'slide-down';
},
dropVisible () {
let status = true;
if (!this.loading && this.remote && this.query === '' && !this.options.length) status = false;
return this.visible && status;
}
},
methods: {
@ -203,7 +205,6 @@
if (this.disabled) {
return false;
}
this.visible = !this.visible;
},
hideMenu () {
@ -224,7 +225,7 @@
child.$children.forEach((innerChild) => {
find(innerChild, cb);
});
})
});
}
};