我有下面的類片段:訪問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事件的方法調用 –