-
-
Save markshust/801c26310e2e82c10f90172e93897326 to your computer and use it in GitHub Desktop.
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 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