首页 > 其他分享 >vue-element-ui中的table 针对于一列中不同的数据添加不同的样式

vue-element-ui中的table 针对于一列中不同的数据添加不同的样式

时间:2022-08-18 12:12:07浏览次数:56  
标签:vue color element nth 字段 important ui table type

针对table中的row中的值给出不同的样式

 解决方案;

    1.在<el-table>标签中添加属性 ;

      实例

      <el-table             :data="tableData"             style="width: 100%"             height="800"             @selection-change="handleSelectionChange"             :row-class-name="tableRowClassName"           >     2.利用这个函数进全局的循环,循环出所有的数据进行匹配,返回一个class名称,根据不同的名称,更改不同的样式         tableRowClassName({row, rowIndex} ){             for(let i=0; i<this.tableData.length;i++){                   if(this.tableData[i].jobState =="字段1"){                       return 'redStyle'                   }else if(this.tableData[i].jobState =="字段2"){                       return 'greenStyle'                                 }else if(this.tableData[i].jobState =="字段3"){                       return 'blueStyle'
                  }else if(this.tableData[i].jobState =="字段4" || this.tableData[i].jobState =="字段5"){                       return 'orangeStyle'                   }               }         },       字段1,字段2,字段3,字段4,字段5 就需要进行匹配的字段名称        redStyle ,greenStyle,blueStyle,orangeStyle 是class名称            ::v-deep .redStyle{         .el-table__cell{          &:nth-of-type(2){ color: #ff5400 !important;}             &:nth-of-type(3){ color: #FF1717 !important;}             &:nth-of-type(6){ color: #ccc !important;}         }       }     ::v-deep .greenStyle{       .el-table__cell{           &:nth-of-type(2){ color: #0CD09C  !important;}           &:nth-of-type(3){ color: #0CD09C  !important;}           &:nth-of-type(6){ color: #0CD09C  !important;}        }     }     ::v-deep .blueStyle{         .el-table__cell{           &:nth-of-type(2){ color: #5231FF !important;}           &:nth-of-type(3){ color: #5231FF !important;}           &:nth-of-type(6){ color: #5231FF !important;}         }     }     ::v-deep .orangeStyle{        .el-table__cell{           &:nth-of-type(2){ color: #FF9500 !important;}           &:nth-of-type(3){ color: #FF9500 !important;}           &:nth-of-type(6){ color: #FF9500 !important;}         }     }       

标签:vue,color,element,nth,字段,important,ui,table,type
From: https://www.cnblogs.com/rockyjs/p/16598235.html

相关文章

  • vue 针对多端口的情况下文件上传处理方法
    在一个项目中,可能会存在多个端口号,因为不同的业务作为区分,需要多个端口号:解决方案,·1.在特定的端口号中api接口中进行加入特定的字符2.针对api的形式,使用form......
  • layui数据表格的渲染方式--方法渲染
    layui数据表格的方法渲染html代码<tableclass="layui-table"id="test"lay-filter="test"></table> js代码<scripttype="text/javascript">......
  • vue 片区公司关联
    //片区公司关联constassociationChange=async(areaId,companyId,type)=>{letlist=awaitGetCompanyList({areaId:areaId,......
  • vue 2 坑编译系统
    errorin./src/components/NumberInfo/NumberInfo.vue?vue&type=style&index=0&id=4370c5af&lang=less&scoped=true&SyntaxError:TypeError:Cannotsetproperty'pare......
  • Vue学习笔记4-项目开发规范及插件
    Vue学习笔记4-项目开发规范及插件一、安装插件首先搜索安装ESLint和Prettier这两个插件。这里对开发规范的配置仅配置ESLint,对代码格式的配置仅配置Prettier,用于代......
  • Vue面试题03:Vue生命周期相关
    生命周期相关定义:每个Vue组件实例在创建时都需要经历一系列的初始化步骤,比如数据监测,模板编译,挂载实例到DOM,以及在数据改变时更新DOM。在此过程中会运行被称为生命......
  • CodeForces-1469C Building a Fence
    BuildingaFencedp模拟?维护好可摆放的区间即可,我用的区间是指当前位置可摆放的东西的下边界区间下限:\(l_i=max(l_{i+1}-k,h_i)\),表示尽量往下放,以及在地面之上......
  • 当使用cube-ui的scroll组件进行scrollTo()滚动的时候,iphone手机上失效的解决办法
    在使用cube-ui的scrollTo()进行页面的滚动时,安卓和浏览器都是正常的,但是在iphone的手机上不能滚动经过排查发现是cube-ui的版本问题,当使用1.12.47版本的时候会出现这个问题......
  • 认识Vue扩展插件
    众所周知,在Vue开发中,实现一个功能可以有很多种方式可以选择,这依赖于Vue强大的功能(指令、混合、过滤等)Vue插件插件通常用来为Vue添加全局功能。插件的功能范围没......
  • element 同时校验循环遍历的多个表单
    <divv-for="(arg,index)inlist":key="index"><el-formref="`form-${index+1}`":model="arg"></el-form></div>letcount=0list.forEach((v,i)=......