This commit is contained in:
lifenglu 2019-10-14 11:42:58 +08:00
parent d5c7ce3017
commit 8b7c5c249a
3 changed files with 32 additions and 19 deletions

View file

@ -1,6 +1,15 @@
<template> <template>
<div style="margin: 100px;width: 200px;"> <div style="margin: 100px;width: 200px;">
<AutoComplete placement="top" transfer v-model="value" icon="ios-search" :data="data" @on-search="handleSearch" @on-change="hc" :filter-method="fm"> <AutoComplete
placement="top"
transfer
v-model="value"
icon="ios-search"
:data="data"
@on-search="onHandleSearch"
@on-change="onChange"
@on-select="onSelect"
>
<!--<Option v-for="item in data" :value="item" :label="item" :key="item">--> <!--<Option v-for="item in data" :value="item" :label="item" :key="item">-->
<!--<span style="color: red">{{ item }}</span>--> <!--<span style="color: red">{{ item }}</span>-->
<!--</Option>--> <!--</Option>-->
@ -8,29 +17,31 @@
</div> </div>
</template> </template>
<script> <script>
export default { export default {
props: { props: {},
},
data () { data () {
return { return {
value: '', value: "",
data: [], source: ["1", "2", "3", "11", "12", "13"],
// data: ['Burns Bay Road', 'Downing Street', 'Wall Street'] data: []
}; };
}, },
computed: {}, computed: {},
methods: { methods: {
handleSearch (value) { onHandleSearch (value) {
this.data = !value ? [] : [ let result = [];
value + '@qq.com', for (let val of this.source) {
value + '@sina.com', if (val.includes(value)) {
value + '@163.com' result.push(val);
] }
}
this.data = result;
}, },
hc (v) { onSelect (e) {
// console.log(v) console.log('onSelect', e);
},
onChange (v) {
console.log("onChange", v);
}, },
fm (value, item) { fm (value, item) {
return item.toUpperCase().indexOf(value.toUpperCase()) !== -1; return item.toUpperCase().indexOf(value.toUpperCase()) !== -1;

View file

@ -13,7 +13,7 @@
remote remote
auto-complete auto-complete
:remote-method="remoteMethod" :remote-method="remoteMethod"
@on-change="handleChange" @on-select="handleSelect"
@on-clickoutside="handleClickOutside" @on-clickoutside="handleClickOutside"
:transfer="transfer"> :transfer="transfer">
<slot name="input"> <slot name="input">
@ -152,9 +152,10 @@
remoteMethod (query) { remoteMethod (query) {
this.$emit('on-search', query); this.$emit('on-search', query);
}, },
handleChange (val) { handleSelect (val) {
if (val === undefined || val === null) return; if (val === undefined || val === null) return;
this.currentValue = val; this.currentValue = val;
this.$refs.input.blur(); this.$refs.input.blur();
this.$emit('on-select', val); this.$emit('on-select', val);
}, },

View file

@ -661,6 +661,7 @@
if (!this.autoComplete) this.$nextTick(() => inputField.focus()); if (!this.autoComplete) this.$nextTick(() => inputField.focus());
} }
this.broadcast('Drop', 'on-update-popper'); this.broadcast('Drop', 'on-update-popper');
this.$emit('on-select', this.publicValue); // # 4441
setTimeout(() => { setTimeout(() => {
this.filterQueryChange = false; this.filterQueryChange = false;
}, ANIMATION_TIMEOUT); }, ANIMATION_TIMEOUT);