tableColumns(data) { let colums = [ { label: "统计月份", prop: "reportDate", labelWidth: 150, align: 'center', type: "month", width: '120px', search: true, hide: true, searchValue: this.query.reportDate, span: 24, addDisplay: false, editDisplay: false, viewDisplay: false, format: "yyyy年MM月", valueFormat: "yyyy-MM-dd hh:mm:ss", value: this.query.reportDate }, // table列 { prop: "enterpriseName1", span: 24, addDisplay: false, editDisplay: false, viewDisplay: false, align: 'center', children: [{ label: "企业名称", prop: "enterpriseName2", addDisplay: false, editDisplay: false, viewDisplay: false, align: 'center', children: [{ label: '合计', prop: "enterpriseName", align: 'center', width: 220, search: true, searchLabelWidth: 110, searchLabel: '企业名称', addDisplay: false, editDisplay: false, viewDisplay: false }] }] },]; data.forEach((item, index) => { if(item.dictValue=='产销比' || item.dictValue=='营业收入' ||item.dictValue=='营业利润'){ colums.push({ label: "", align: 'center', showHeader:false, addDisplay: false, editDisplay: false, viewDisplay: false, span: 24, }); }else{ colums.push({ label: item.dictValue, align: 'center', addDisplay: false, editDisplay: false, viewDisplay: false, span: 24, children: [ { label: ${this.monthLable}, prop: "yearValueSum", align: 'right', addDisplay: false, editDisplay: false, viewDisplay: false, children: [{ headerslot: true, align: 'right', prop: "yearValue" + index, addDisplay: false, editDisplay: false, viewDisplay: false, }] }, { label: "上年同期", prop: "yearBeforeValueSum", align: 'right', addDisplay: false, editDisplay: false, viewDisplay: false, children: [{ headerslot: true, align: 'right', prop: "yearBeforeValue" + index, addDisplay: false, editDisplay: false, viewDisplay: false, }] },我要怎么删除表头为空
时间: 2024-02-06 12:04:17 浏览: 99
MySQL:The used SELECT statements have a different number of columns
的那一列呢?
你可以在循环 `colums` 的时候加上一个判断条件,如果该列的 `label` 为空,则将其从 `colums` 数组中删除,方法如下:
```javascript
for (let i = 0; i < colums.length; i++) {
if (!colums[i].label) {
colums.splice(i, 1);
i--;
}
}
```
这样就可以删除表头为空的那一列了。
阅读全文