为了在ElementUI的表格(el-table)中针对特定列设置背景颜色,你可以利用cell-class-name属性或cell-style属性来自定义列的样式。这里我将分别介绍这两种方法,并提供相应的代码示例。 方法一:使用cell-class-name属性 cell-class-name属性允许你根据每行每列的数据动态地添加类名,从而可以在CSS中定义这些类的样式。 定...
一个用来控制头部颜色,rowIndex的下标为0表示的就是第一个,这样就可以给第一个设置颜色了。 也就是: element-ui如何自定义表格颜色-核心代码: //控制行颜色 tableRowClassName ({ row, rowIndex }) { if ((rowIndex + 1) % 2 === 0) { return 'double'; //对应的类 } else { return 'single';...
1.行背景色 table 组件提供了row-style属性,说明:行的style的回调方法,也可以使用一个固定的Object为所有行设置一样的Style。 于是我们可以在method中写一个setRowStyle方法,通过行索引和背景色数组去匹配颜色值用于单元格背景色。 setRowStyle({row, rowIndex}) { return { 'background-color': this.rowsBgColo...
ElementUI的el-table表格使用cell-style根据表格不同数据显示不同颜色 1.在表格中添加属性 在el-table标签中添加 :cell-style="cellStayle" <el-table:data="tableData"stripeclass=""style="width: 100%":cell-style="cellStayle"><el-table-columntype="index"width="50"label="序号"></el-table-column>...
简介:vue element-ui中有关表格中的数据整条显示红色/绿色等等颜色的问题 今天写了一些代码,是有关合同审核成功之后,整条数据显示绿色,针对已经作废的数据整条显示红色。以下是解决方案。 1 在表格头添加。:cell-style="tableRowClassName" <el-table :cell-style="tableRowClassName"></<el-table> ...
<style scoped lang="less"> /deep/ .el-table__header .el-table__cell{ background-color: var(--el-fill-color-lighter) !important; } <
假设有这样一个需求,就是我们有数据表格,用来记录学生是否处于上学和辍学的状态。辍学的状态加上个背景色,作为提醒。最终效果如下图 代码附上 <template><divid="app"><el-table:data="tableData"border:header-cell-style="{background: '#fafafa',color: '#333',fontWeight: '600',fontSize: '14px',}...
设置表格内容的样式、颜色 <el-table:data="table":header-cell-style="thStyleFun":cell-style="cellStyleFun"class="main-table"@selection-change="selectRow"><el-table-columntype="selection"width="50"></el-table-column><el-table-columnprop="nodeName"label="节点名称"></el-table-column><el-...