How to implement debounce in Vue2?

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

    If you could move the execution of the debounce function into some class method you could use a decorator from the utils-decorators lib (npm install --save utils-decorators):

    import {debounce} from 'utils-decorators';
    
    class SomeService {
    
      @debounce(500)
      getData(params) {
      }
    }
    

提交回复
热议问题