xxxxxxxxxx
npm i --save lodash
import { debounce } from 'lodash';
<script>
const searchQuery = ref(null);
const search = () => {
axios.get('/api/users/search', {
params: {
query: searchQuery.value,
}
}).then(response => {
users.value = response.data;
}).catch(error => {
console.log(error)
});
}
watch(searchQuery, debounce(() => {
search();
}, 300))
</script>
<input type="text" v-model="searchQuery" class="form-control" placeholder="Search..." />