Created
December 3, 2023 13:20
-
-
Save markshust/ae671cd7a0f93033f01a2e2883b1b3c6 to your computer and use it in GitHub Desktop.
Nuxt Content VueJS v2 Debounce Input
This file contains hidden or 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" | |
@input="debounceSearch()" | |
v-model="search" | |
/> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
search: '', | |
} | |
}, | |
methods: { | |
triggerSearch() { | |
alert(this.search); | |
}, | |
debounceSearch: function() { | |
if (this.debounceTimeout) clearTimeout(this.debounceTimeout); | |
this.debounceTimeout = setTimeout(() => { | |
this.filterBlog(); | |
}, 500); | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment