我知道我不应该使用地图,因为因为我不能遍历一个对象。我只是不知道要用什么来检查拳头物体。



ngOnInit() {
  this.chartsService.getAOD().subscribe(data => {
    (this.data as any) = data;
    console.log(this.data);
    this.data.map(values => {
      console.log(values);
    });
  });
  this.chartOptions();
}





javascript - 访问第一个对象及其内部的数组-LMLPHP

最佳答案

对象上的三种静态方法提供对象的可迭代性

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();
}

09-10 11:58
查看更多