Created
October 22, 2020 10:41
-
-
Save MexsonFernandes/d99d68160c3f256298b6d20228595f78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<input | |
type="text" | |
placeholder="Search Your Interest" | |
@input="debounceSearch()" | |
v-model="searchInput" | |
/> | |
</div> | |
</template> | |
<script> | |
export default { | |
data: () => { | |
return { | |
debounceTimeout: null, | |
searchInput: "" | |
}; | |
}, | |
methods: { | |
filterBlog() { | |
alert(this.searchInput); | |
}, | |
debounceSearch: function() { | |
if (this.debounceTimeout) clearTimeout(this.debounceTimeout); | |
this.debounceTimeout = setTimeout(() => { | |
this.filterBlog(); | |
}, 500); // delay for half second | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you