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 浏览: 24
的那一列呢?
你可以在循环 `colums` 的时候加上一个判断条件,如果该列的 `label` 为空,则将其从 `colums` 数组中删除,方法如下:
```javascript
for (let i = 0; i < colums.length; i++) {
if (!colums[i].label) {
colums.splice(i, 1);
i--;
}
}
```
这样就可以删除表头为空的那一列了。
相关问题
TypeError: __init__() got an unexpected keyword argument 'colums'
This error message indicates that there is a typo in the code where the argument 'colums' is being passed to the __init__() method of a class. The correct argument should be 'columns' instead of 'colums'.
For example, if you have a class named 'Dataframe' with an __init__() method that takes a 'columns' argument, the correct code would be:
```
class Dataframe:
def __init__(self, columns):
self.columns = columns
```
If you passed 'colums' instead of 'columns' when creating an instance of the Dataframe class, you would get the TypeError mentioned in the error message.
AA = pd.DataFrame(*A.Data, index=A.Times,colums=3Y)
这个语句存在一些语法错误,应该改为:
```python
AA = pd.DataFrame(A.Data, index=A.Times, columns=['3Y'])
```
这个语句的作用是,将一个名为 `A` 的对象的 `Data` 属性作为数据,`Times` 属性作为索引,创建一个新的 DataFrame 对象,并将其赋值给 `AA` 变量。其中 `pd` 是 pandas 库的别名,需要先导入才能使用。
在上面的语句中,`A.Data` 是一个二维列表,表示 DataFrame 中的数据,`A.Times` 是一个一维列表,表示 DataFrame 中的索引。`columns=['3Y']` 表示 DataFrame 中只有一列,列名为 `3Y`。
需要注意的是,`columns` 参数应该是一个列表或者其他可迭代对象,表示 DataFrame 中的列名。在原来的语句中,参数使用了错误的语法,应该改为 `columns=['3Y']`。