input输入时触发ajax请求事件 在这个时候如何实现函数防抖
searchInput(e){
this.setState({
searchContent:e.target.value
})
fetch(`/api/book/auto-complete?query=${e.target.value}`)
.then(res=>res.json())
.then(res=>{
console.log(res);
this.setState({
completionArr:res.keywords
})
})
}
加个定时器
setTimeout
即可