我有同样的打字稿组件两种功能。当我尝试调用已声明的一个时,VSCode报告它“[ts]找不到名称'XXX'。”。
按照要求通过Tiep Phan,这是全码:
liveSearchFMs(input: any) {
this._ectmService.getFMsFromUserSearch(input).subscribe(
fanmissions => this.fanmissions = fanmissions,
error => this.errorMessage = <any>error
);
}
timeout(input) {
var enteredValue = input;
var timeout = null;
clearTimeout(timeout);
timeout = setTimeout(function() {
this.liveSearchFMs(enteredValue);
}, 1000);
}
显示你的代码而不提示 –
使用箭头功能或者存储上下文我的回答下面将解决您的问题 –
我一直看到这一点,这让没有意义:'error => this.errorMessage =错误'。为什么类型断言?即使他错了,人们是否会模仿沃德贝尔? –