我知道我不应该使用地图,因为因为我不能遍历一个对象。我只是不知道要用什么来检查拳头物体。
ngOnInit() {
this.chartsService.getAOD().subscribe(data => {
(this.data as any) = data;
console.log(this.data);
this.data.map(values => {
console.log(values);
});
});
this.chartOptions();
}
最佳答案
对象上的三种静态方法提供对象的可迭代性
ngOnInit() {
this.chartsService.getAOD().subscribe(data => {
(this.data as any) = data;
Object.entries(this.data).map(([key, value]) => console.log(key, value));
Object.keys(this.data).map((key) => console.log(key));
Object.values(this.data).map((value) => console.log(value));
});
this.chartOptions();
}