【发布时间】:2021-11-23 18:19:30
【问题描述】:
我正在尝试在 Angular 12 中声明以下变量
private subject = new BehaviorSubject<ApiResponse>({});
我得到错误
Argument of type '{}' is not assignable to parameter of type 'ApiResponse'
Type '{}' is missing the following properties from type 'ApiResponse'
类 ApiResponse 具有以下属性
export interface ApiResponse {
success: boolean
message: string
exception: any
totalRowCount: number
}
如果我明确声明每个属性,它可以正常工作 有没有办法在不显式声明每个属性的情况下声明一个空对象?
【问题讨论】:
标签: angular