【发布时间】:2021-08-24 00:35:05
【问题描述】:
在 Angular 项目中,我使用的是接口。
export interface School {
name: string = '';
website: string;
registrationNumber: string;
dateEstablished: Date;
address: string;
country: [];
companyLogo: any = '';
clear() {
this.name = '';
this.website = '';
this.registrationNumber = '';
this.dateEstablished = null;
this.address = '';
this.country = [];
this.companyLogo = '';
}
}
我有两个错误:
-
对象可能是“未定义的”——以及所有的“这个”。突出显示
-
预期的声明或声明.ts(1128) - 最后一个右大括号突出显示。
-
预期的呼叫签名:'clear' 有一个 typedef (typedef)tslint(typedef)
我如何解决这些问题?
谢谢
【问题讨论】:
-
我可能弄错了,但我不认为接口可以包含方法实现。接口描述了接口的具体实现中应该存在的成员。它们不包含它们的定义。您是否看到了相反的信息?
-
@JLRishe - 最好的方法是什么。请指教
标签: angular