Skip to content

Instantly share code, notes, and snippets.

@eserdinyo
Created June 13, 2020 08:22
Show Gist options
  • Save eserdinyo/8bd964e0767d9de3fab181faa039769d to your computer and use it in GitHub Desktop.
Save eserdinyo/8bd964e0767d9de3fab181faa039769d to your computer and use it in GitHub Desktop.
search timer
<template>
<input
v-model="searchWord"
class="searchbar__search--form-input"
type="text"
placeholder="Search"
autocomplete="off"
@keyup="handleSearch"
@blur="closeResult"
>
</template>
<script>
data(){
return {
queryTimer: null,
searchWord: ''
}
}
methods: {
handleSearch () {
if (this.searchWord.length >= 3) {
clearTimeout(this.queryTimer)
this.queryTimer = setTimeout(() => {
this.search(this.searchWord)
}, 300)
}
},
search (word) {
console.log('...')
},
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment