我的电话上有这个电话component page
this.timerSessionService.startTimer(this.finish.bind(this), this.onSynchronice);
嗯,它与this.finish
,但是当我打电话时onSynchronice
从我的Service
它仍然有效并转到我的component
问题出现在我的component
我尝试使用调用组件内部的函数.this
, 它说:
错误错误:未捕获(承诺中):TypeError:无法设置未定义的属性“pew”
这是因为在我的onSynchronice
我使用的函数.this
然后它说它不存在...我该如何修复它?
在我的组件上
onSynchronice(pew) {
console.log(pew["pew"]); //Works perfect
this.pew= pew; //Crashes because of .this
this.anyfunction(pew); //It crashes and says the same, anyfunction() does not exist, even if it exists
}
您可以定义onSynchronice
作为箭头函数:
onSynchronice = (pew) => {
console.log(pew["pew"]);
this.pew= pew;
this.anyfunction(pew);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)