-
-
Save ArielMejiaDev/acaf474132ebf46972d495e618c04504 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