Created
June 13, 2020 08:22
-
-
Save eserdinyo/8bd964e0767d9de3fab181faa039769d to your computer and use it in GitHub Desktop.
search timer
This file contains 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> | |
<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