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

View file

@ -1,36 +1,47 @@
<template>
<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">-->
<!--<span style="color: red">{{ item }}</span>-->
<!--<span style="color: red">{{ item }}</span>-->
<!--</Option>-->
</AutoComplete>
</div>
</template>
<script>
export default {
props: {
},
props: {},
data () {
return {
value: '',
data: [],
// data: ['Burns Bay Road', 'Downing Street', 'Wall Street']
value: "",
source: ["1", "2", "3", "11", "12", "13"],
data: []
};
},
computed: {},
methods: {
handleSearch (value) {
this.data = !value ? [] : [
value + '@qq.com',
value + '@sina.com',
value + '@163.com'
]
onHandleSearch (value) {
let result = [];
for (let val of this.source) {
if (val.includes(value)) {
result.push(val);
}
}
this.data = result;
},
hc (v) {
// console.log(v)
onSelect (e) {
console.log('onSelect', e);
},
onChange (v) {
console.log("onChange", v);
},
fm (value, item) {
return item.toUpperCase().indexOf(value.toUpperCase()) !== -1;

View file

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

View file

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