防抖-小程序-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}) // 计时器
},