问题描述:
关于Angular 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)
}
}
解决方案:
将js代码中的quoteList = []; 改为 quoteList:any[] = [];
|