给el-table动态添加竖线分割
给el-table动态添加竖线分割
需求:每隔4个列添加一个竖线分割
vue文件:
结构:
<!-- 给某个td里面添加类名:cell-class-name -->
<el-table
:data="dataList"
size="mini"
border
@selection-change="selectionChangeHandle"
:cell-class-name="addSeparate"
>
</el-table>
样式:
<style>
/* 不能写scoped,否侧会不生效 */
.separator-border {
border-right: 1px solid #eeeff2!important;
}
</style>
js文件:
addSeparate(row) {
if (row.columnIndex % 4 == 0) {
return "separator-border"
}
}