问题描述:
关于Angular2+ NgForOf下item.xxx的使用报错:Property ‘***’ does not exist on type ‘never’.
<div *ngFor="let item of quoteList">
<div>
<h3>{{item.quote.name}}</h3>
<div>{{item.quote.current}}</div>
<p>+{{item.quote.chg}}(+{{item.quote.percent}})</p>
</div>
<div class="svg">
</div>
</div>
</div>
export class MainComponent implements OnInit {
quoteList = []; //问题出在这里
constructor() {
this.getData();
}
ngOnInit(): void {
}
async getData() {
let httpUrl = "http://localhost:8080/api/index/quote";
let result = await axios.get(httpUrl);
this.quoteList = result.data.data.items;
console.log(this.quoteList)
}
}
本文介绍了在Angular 2中使用NgForOf遍历时遇到的Property '***' does not exist on type 'never'错误,通过将初始的quoteList声明改为any类型数组来解决,同时提供了详细的代码示例和解决步骤。
3842

被折叠的 条评论
为什么被折叠?



