欢迎加QQ交流:
2
0
2
3

防抖-小程序-input输入频繁时搜索出bug

html:

<input type="text" class="input_search" placeholder="搜索周边店铺" bindinput='getInputValue'></input>
 
js:
  getInputValue(e) {
    let {input_timeOut} = this.data
    if(input_timeOut) {
      clearTimeout(input_timeOut)
    }
    input_timeOut = setTimeout(() => {
      this.setData({inputValue: e.detail.value}) // value,获取到的值
    }, 300);
    this.setData({input_timeOut}) // 计时器

  },
posted @ 2022-03-09 16:14  常安·  阅读(107)  评论(0编辑  收藏  举报