How to implement debounce in Vue2?

前端 未结 13 666
梦谈多话
梦谈多话 2020-11-27 11:08

I have a simple input box in a Vue template and I would like to use debounce more or less like this:



        
13条回答
  •  温柔的废话
    2020-11-27 11:21

    Very simple without lodash

      handleScroll: function() {
        if (this.timeout) 
          clearTimeout(this.timeout); 
    
        this.timeout = setTimeout(() => {
          // your action
        }, 200); // delay
      }
    

提交回复
热议问题