将二维数组转化成一维数组

<st #st [columns]="columns" [data]="data" [bordered]='true'>
  <ng-template st-row="demoType" let-item let-index="index" let-column="column">
    <img [src]="subItem"  width="30px" height="30px" *ngFor="let subItem of item.Content"/>
  </ng-template>
</st>
import { Component, OnInit } from '@angular/core';
import { STColumn } from '@delon/abc';
@Component({
  selector: 'app-card-whole-consume',
  templateUrl: './card-whole-consume.component.html',
  styleUrls: ['./card-whole-consume.component.css']
})
export class CardWholeConsumeComponent implements OnInit {
  data;
  flattenedData = [];
  columns: STColumn[] = [
    {
      title: '姓名',
      index: 'Name',
    },
    {
      title: '账号',
      index: 'Account',
    },
    {
      title: '图片',
      index: 'Content',
      render: 'demoType'
    }
  ];
  constructor() { }
  ngOnInit() {
    this.data = [
      { Name: 'hanxiaoye', Account: '13788886666', Content: [['http://xx.jpg'], ['http://jj.jpg']]},
      { Name: '王五', Account: '1380013801', Content: [['http://cc.jpg']]},
    ];
    for (const item of this.data) {
      item.Content = item.Content.reduce(( acc , cur ) => acc.concat(cur) );
    }
  }
}
原文地址:https://www.cnblogs.com/yuyedaocao/p/11011168.html