使用setTimeout上的箭头功能为遗嘱父母道具做
setTimeout( () => { this.resetNotification(); }......
如果你还想使用 function () {} 语法,你可以通过 this 作为函数的第一个参数,以及类型注释。像这样:
function () {}
this
setTimeout( function(this: Board) { this.resetNotification(); } .bind(this), 500 );
我假设自从文件被调用 Board.tsx 你的组件是 <Board> 。如果不是,请更改类型注释 this 。
Board.tsx
<Board>