0
I come from Angularjs and, at certain times, when I need to make a query according to what the user is searching, I use ng-change
, but I agree with him ng-model-options="{debounce: 500}"
. This makes the angular queries do not trigger queries as crazy on my server, but causes the search to be done only when you stop typing.
I wanted to do the same thing with Vue, but the option debounce
was depreciated in version 2.0+.
What now? How could I do in Vuejs to be able to run a @input
only when the user stops typing?
There’s that in Vuejs ready, or I’ll have to do "in hand"?
Example:
<input type="text"
v-model="pesquisa.nome"
@input="consultarSoQuandoPararDeDigitar()" />
In "pure" Vue no longer has it ready, you need to use an external package, or implement on your own. The lodash library can be used for a simple implementation. Unfortunately I don’t have time to post a response.
– bfavaretto
@bfavaretto um... I’m already doing a scheme that I always use with
setTimeOut
. Anything, put here, but I’ll wait for an answer for now.– Wallace Maxters
I use https://www.npmjs.com/package/debounce
– vinibrsl