属性“listing”没有初始值设定项,并且在constructor.ts(2564)中没有明确分配

时间:2021-04-26 14:46:46

标签: angular typescript compiler-errors

我刚刚开始学习 angular,我无法解决这个初始化错误。enter image description here 请帮我解决。

1 个答案:

答案 0 :(得分:0)

首先,尝试粘贴代码而不是上传其屏幕截图。其次,尝试将数组初始化为空数组。

listing: Listing[] = [];

当您在 ngOnInit 方法中为它分配一个数组时。