Skip to content

Instantly share code, notes, and snippets.

@markshust
Forked from MexsonFernandes/debounce-nuxt.vue
Created December 3, 2023 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markshust/801c26310e2e82c10f90172e93897326 to your computer and use it in GitHub Desktop.
Save markshust/801c26310e2e82c10f90172e93897326 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