【发布时间】:2023-02-22 22:30:38
【问题描述】:
功能一:
getDescr() {
this.idResponse = this.descriptor.getDescriptors(this.descriptorSelected).subscribe(
(data) => {
this.idResponse = data;
this.idResponse.values.processingParameters.forEach(function (value: any){
this.addParameters(value.id);
});
console.log;
},
error => {
this.httpErrors.httpErrors.message = error.error.error;
}
)
}
功能二:
addParameters (value: string): void{
switch (value){
case 'DOCUMENT_TYPE': {
console.log('--> DT')
break;
}
case 'EMAIL': {
console.log('--> EMAIL')
break
}
}
}
当我在函数 1 中调用 addParameters 时出现错误:
'this' implicitly has type 'any' because it does not have a type annotation
你能告诉我为什么吗?我应该改变什么?
【问题讨论】:
-
请edit问题中的代码是一个独立的minimal reproducible example,我们可以将其按原样粘贴到我们自己的 IDE 中,并查看您看到的问题而没有不相关的问题(例如,缺少声明)。否则,您得到的任何答案都必然未经测试,因此不太可能提供帮助。
标签: angular typescript