Skip to content

Instantly share code, notes, and snippets.

@ArielMejiaDev
Forked from MexsonFernandes/debounce-nuxt.vue
Created August 17, 2023 07:26
Show Gist options
  • Save ArielMejiaDev/acaf474132ebf46972d495e618c04504 to your computer and use it in GitHub Desktop.
Save ArielMejiaDev/acaf474132ebf46972d495e618c04504 to your computer and use it in GitHub Desktop.
<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