el-table 动态生成表头
el-table 根据后端返回的数据,动态生成表头并展示相应的值。如后端返回的数据如下:
// 处理后端返回的数据data,并定义queryColumns存储label作为表头
this.queryResult = response.data;
response.data.map((item) => {
Object.keys(item).map((key) => {
!this.queryColumns.includes(key) && this.queryColumns.push(key);
});
});
// 循环绑定