Vue refuses a method?

I know that Vue.js has built-in functions for debugging in the input field. I created a slider that runs a method that does not use an input field, although I was wondering if I could use the debounce functionality inside the method.

Is it possible to use this function beyond just adding debugging to the input? Or do I need to write my own functions for this?

I just tried to do something like this, but it does not work:

this.$options.filters.debounce(this.search(), 2000); 
+6
source share
2 answers

For those who are wondering how to do this. I fixed this using an amazing little snippet that I found:

Attribute in my data

 timer: 0 

Debugging functionality

 // clears the timer on a call so there is always x seconds in between calls clearTimeout(this.timer); // if the timer resets before it hits 150ms it will not run this.timer = setTimeout(function(){ this.search() }.bind(this), 150); 
+9
source

The result of this.search () is called in debounce, try the following:

 var bufferSearch = Vue.options.filters.debounce(this.search.bind(this), 150); bufferSearch(); 
+4
source

All Articles