1,通过样式控制 首先定义行class样式 在组件中需通过样式穿透
::v-deep {
.row-expand-unhas .el-table__expand-column {
pointer-events: none;
}
.row-expand-unhas .el-table__expand-column .el-icon {
visibility: hidden;
}
}
2,行判断数据条件 添加class
<el-table
ref="tableRef"
:data="tableData"
style="width: 100%"
row-key="id"
border
:height="tableHeight"
:row-class-name="getRowClass"
@expand-change="handleExpandChange"
>
<el-table-column type="expand">
<template #default="props">
....
</template>
</el-table-column>
// 根据是否合计行判断是否隐藏展开按钮
getRowClass({row}) {
const res = []
if (row.sector !== '合计') {
res.push('row-expand-has')
return res
} else {
res.push('row-expand-unhas')
return res
}
},
3.最终效果
