使い方
アロー関数を使う。
setTimeout(() => {
this.hoge = true
}, 2000)
this をクロージャー変数に置き換える。
const self = this;
setTimeout(function(){
self.hoge = true;
}, 2000);
this を bind する。
setTimeout(function(){
this.hoge = true;
}.bind(this), 2000);
参考: