我将 lodash debounce 添加到我的输入中,我想使用它。我用 console.logs 检查了方法,但它从未进入去抖部分。
const debounce = require('lodash/debounce');
filterFeed(event: any){
// event.preventDefault()
event.persist();
debounce(() => {
let searchString = event.target.value;
let unfilteredFeed: any = this.unfilteredFeed;
let filteredFeed: any = unfilteredFeed.filter(el => el.title.toLowerCase().includes(event.target.value.toLowerCase()));
this.setState({ input: searchString, feed: filteredFeed, filter: true })
}, 300);
}
<input className="basic-slide" id="name" type="text" value={this.state.input} placeholder="Event..." onChange={ this.filterFeed.bind(this)} /><label >Suche</label>
慕的地6264312
守着星空守着你
慕哥6287543
相关分类