张念磊的博客

前端技术 - 查询搜索时的防抖

2020-05-18

1
2
3
4
5
6
7
8
9
10
11
12
13
14
async queryUserByChunk(search) {
clearTimeout(this.timeout) // this.timeout 是一个全局变量
let param = {
corporationNo: localStorage.getItem("orgAcct"),
searchParam: search
};
this.timeout = setTimeout(() => {
findUserByUsernameOrRealNameOrJobNo(param)
.then(res => {
// do some thing...
})
.catch(error => {});
}, 300);
}

扫描二维码,分享此文章