feat: add emit in auto compelete

pull/50/head
Saeid 4 years ago
parent 7413c75af3
commit 3fb66d8331

@ -1,36 +1,37 @@
<template>
<div>
<slot :filter="filter"> </slot>
</div>
<div>
<slot :filter="filter"></slot>
</div>
</template>
<script>
let cancelId;
let cancelId;
export default {
name: "AutoCompleteWrapper",
props: {
callback: {
type: Function,
},
},
methods: {
filter(e) {
clearTimeout(cancelId);
if (
e.target.value &&
e.target.value.length > 1 &&
e.code !== "Tab" &&
e.code !== "Enter"
) {
cancelId = setTimeout(() => {
this.callback(e.target.value);
}, 400);
}
},
},
};
export default {
name: "AutoCompleteWrapper",
props: {
callback: {
type: Function,
},
},
methods: {
filter(e) {
clearTimeout(cancelId);
if (
e.target.value &&
e.target.value.length > 1 &&
e.code !== "Tab" &&
e.code !== "Enter"
) {
cancelId = setTimeout(() => {
this.$emit('filter', e.target.value);
this.callback(e.target.value);
}, 400);
}
},
},
};
</script>
<style>
</style>
</style>

Loading…
Cancel
Save