当前位置: 首页 > news >正文

Vue 学习随笔系列十七 -- 表格样式修改

表格样式修改

文章目录

  • 表格样式修改
    • 一、表格背景颜色修改
      • 1、方法一
      • 2、方法二
    • 二、多级表头颜色修改


一、表格背景颜色修改

1、方法一

表格外套一个 div ,修改div的背景色,并将表格背景色设置为透明
参考代码:

<template><div class="custom-table"><el-tablesize="mini"border:data="tableData":max-height="tableHeight"style="width: 100%"><el-table-columnv-for="(item, index) in tableColumns":key="index"v-bind="item"align="center"></el-table-column><el-table-columnlabel="操作"fixed="right"align="center"width="100"><template slot-scope="scope"><spanclass="del-btn"@click="emitEvent({eventName:'deleteItem',params:scope.row})">删除</span></template></el-table-column>           </el-table></div>
</template><script>export default {props: { tableData: {type: Array,default: () => []},tableHeight: {},tableColumns: {default: () => []}},data() {return { }}, }
</script><style lang="less" scoped>.del-btn {color: #4597EB;cursor: pointer;}.custom-table /deep/ .el-table, .el-table__expaned-cell {background-color: transparent;}.custom-table /deep/ .el-table tr {background-color: transparent !important;}.custom-table /deep/  .el-table--enable-row-transition .el-table__body td, .el-table .cell{background-color: transparent;}.custom-table /deep/ .el-table th.el-table__cell {background: transparent !important; // 表头背景透明}.el-table::before { //去除底部白线left: 0;bottom: 0;width: 100%;height: 0px;}
</style>

2、方法二

直接修改表格背景颜色

<template><div class="custom-table"><el-tablesize="mini"border:data="tableData":max-height="tableHeight"style="width: 100%"><el-table-columnv-for="(item, index) in tableColumns":key="index"v-bind="item"align="center"></el-table-column><el-table-columnlabel="操作"fixed="right"align="center"width="100"><template slot-scope="scope"><spanclass="del-btn"@click="emitEvent({eventName:'deleteItem',params:scope.row})">删除</span></template></el-table-column>           </el-table></div>
</template><script>export default {props: { tableData: {type: Array,default: () => []},tableHeight: {},tableColumns: {default: () => []}},data() {return {}},methods: {emitEvent ({ eventName, params }) {this.$emit(eventName, params)}}, }
</script><style lang="less" scoped>.del-btn {color: #4597EB;cursor: pointer;}.custom-table {background: transparent;}.custom-table /deep/ .el-table th.el-table__cell,/deep/ .el-table tr,/deep/.el-table th {color: '#FFF'; // 表格字体颜色background: red; // 表格背景颜色}</style>

二、多级表头颜色修改

<template><el-table :data="tableData" :header-cell-style="tableHeaderColor" border stripe>
</template><script>
export default {methods: {// 修改表头颜色tableHeaderColor ({ rowIndex, columnIndex }) {if (rowIndex === 0 && columnIndex === 0) {return "background:#D9EAFFFF;";}if (rowIndex === 0 && columnIndex === 2) {return "background: #FFF0E1FF;";}if (rowIndex === 0 && columnIndex === 3) {return "background: #E0F5E9FF;";}if (rowIndex === 0 && columnIndex === 4) {return "background: #D9EAFFFF;";}if (rowIndex === 0 && columnIndex === 5) {return "background: #FFF0E1FF;";}if (rowIndex === 0 && columnIndex === 6) {return "background: #E0F5E9FF;";}},}
}
</script><style></style>
http://www.lryc.cn/news/490539.html

相关文章:

  • 08 —— Webpack打包图片
  • 01.Django快速入门
  • 【大数据学习 | Spark-Core】spark-shell开发
  • Modern Effective C++ Item 14 如果函数不抛出异常请使用noexcept
  • cudatoolkit安装(nvcc -V错误版本解决)
  • DTO和VO的区别及使用场景详解
  • 百度在下一盘大棋
  • 第十六届蓝桥杯模拟赛第二期题解—Java
  • 驱动开发笔记:关于3588GPIO
  • 【RK3588 Linux 5.x 内核编程】-内核线程与Mutex
  • 【0342】分配并初始化 Proc Signal 共享内存 (1)
  • 管家婆财贸ERP BR035.回款利润明细表
  • 数据库MYSQL——表的设计
  • netstat -tuln | grep 27017(显示所有监听状态的 TCP 和 UDP 端口,并且以数字形式显示地址和端口号)
  • 非线性控制器设计原理
  • MySQL数据库6——SQL优化
  • IDEA配置本地maven
  • 学习日记_20241123_聚类方法(高斯混合模型)续
  • SpringMVC——简介及入门
  • 文件操作完成后,为什么要关闭文件
  • vue3+echarts+ant design vue实现进度环形图
  • 使用argo workflow 实现springboot 项目的CI、CD
  • C++知识点总结(58):序列型动态规划
  • go interface(接口)使用
  • 【docker】docker commit 命令 将当前容器的状态保存为一个新的镜像
  • 使用 Java 中的 `String.format` 方法格式化字符串
  • 图论最短路(floyed+ford)
  • BERT的中文问答系统39
  • 从 Mac 远程控制 Windows:一站式配置与实践指南20241123
  • 【Linux学习】【Ubuntu入门】1-5 ubuntu软件安装