我有下面的类片段:访问event.target内回调反应
constructor(props) {
super(props);
this.timeout = null;
}
search = (e) => {
clearTimeout(this.timeout);
this.timeout = setTimeout(
function(){ console.log(e.target); },
500
);
}
<input
type="text"
placeholder="Search by title or author"
onKeyPress={this.search} />
我不能得到设定的超时值从事件打印的价值,是有什么,我应该做的,但我不是?
香港专业教育学院更新的代码包括onkeypress事件的方法调用 –