How to implement debounce in Vue2?

前端 未结 13 692
梦谈多话
梦谈多话 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:39

    We can do with by using few lines of JS code:

    if(typeof window.LIT !== 'undefined') {
          clearTimeout(window.LIT);
    }
    
    window.LIT = setTimeout(() => this.updateTable(), 1000);
    

    Simple solution! Work Perfect! Hope, will be helpful for you guys.

提交回复
热议问题