search

Home  >  Q&A  >  body text

javascript - How do you usually solve the problem of delayed requests after Vue.js2.0 cannot use debounce.

There are often requirements similar to this, such as requesting the corresponding pinyin when the user enters a name. In order to reduce useless requests, the request is initiated after 300ms after the input value has not changed. I currently implement it by directly storing setTimeout in a variable, but my friend said that there are some problems with this, and it is better to use debounce. After searching, I found that vue.js2.0 no longer supports debounce. I would like to ask the experts how to achieve this requirement?

过去多啦不再A梦过去多啦不再A梦2765 days ago848

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-06-28 09:30:57

    Use the debounce method in lodash.

    You can also write one yourself.

    reply
    0
  • Cancelreply