当前位置:   article > 正文

element-plus 表格-自定义样式实现_element plus table表格边框样式

element plus table表格边框样式

效果如下

代码如下

  1. <template>
  2. <h2>表格自定义样式</h2>
  3. <div style="background-color: cadetblue; height: 600px;">
  4. <div class="regulaContainer">
  5. <el-table ref="tableRef" :data="tableData" border style="width: 100%" highlight-current-row height="400"
  6. :cell-style="rowStyleClass">
  7. <el-table-column type="index" label="序号" width="100" />
  8. <el-table-column prop="date" label="Date" width="180" />
  9. <el-table-column prop="name" label="Name" width="180" />
  10. <el-table-column prop="address" label="Address" />
  11. </el-table>
  12. </div>
  13. </div>
  14. </template>
  15. <script lang="ts" setup >
  16. import { getCurrentInstance, onMounted, reactive, ref, inject } from 'vue'
  17. const install = getCurrentInstance();
  18. const tableRef = ref();
  19. const tableData = reactive<any>([])
  20. onMounted(() => {
  21. for (let i = 0; i < 5; i++) {
  22. let obj = {
  23. date: '2016-05-01',
  24. name: 'Tom' + i,
  25. address: 'No. 189, Grove St, Los Angeles',
  26. color_index: i
  27. }
  28. tableData.push(obj);
  29. }
  30. })
  31. function rowStyleClass(row) {
  32. console.log(row.rowIndex)
  33. let style = {};
  34. if (row.rowIndex % 2) {
  35. style = {
  36. color: '#fff',
  37. borderBottom: "1px solid #EBEEF588",
  38. //background: '#065D5F !important'
  39. };
  40. return style;
  41. }
  42. else {
  43. style = {
  44. color: '#fff',
  45. borderBottom: "1px solid #EBEEF588",
  46. //background: '#065D5F !important'
  47. };
  48. return style;
  49. }
  50. }
  51. </script>
  52. <style>
  53. .regulaContainer {
  54. background-color: cadetblue;
  55. }
  56. /* 表格整体背景色 */
  57. .regulaContainer .el-table,
  58. .regulaContainer .el-table__expanded-cell {
  59. background-color: transparent;
  60. }
  61. /* 表格最下面的线 */
  62. .regulaContainer .el-table__inner-wrapper::before {
  63. height: 0px;
  64. }
  65. .regulaContainer .el-table td.el-table__cell,
  66. .regulaContainer .el-table th.el-table__cell.is-leaf {
  67. border: 0px;
  68. }
  69. .regulaContainer .el-table thead {
  70. color: #fff;
  71. background-color: rgb(4, 151, 145);
  72. border: 0;
  73. }
  74. .regulaContainer .el-table th {
  75. background: transparent;
  76. }
  77. /* 表格内tr背景色修改 */
  78. .regulaContainer .el-table tr {
  79. background-color: transparent !important;
  80. border: 1px;
  81. /* 设置字体大小 */
  82. font-size: 16px;
  83. color: #fff;
  84. }
  85. /*表格内td背景色修改*/
  86. .regulaContainer .el-table td {
  87. background-color: transparent !important;
  88. border: 1px;
  89. /* 设置字体大小 */
  90. font-size: 16px;
  91. color: #fff;
  92. }
  93. .regulaContainer .current-row {
  94. /* 选中时的图片显示 */
  95. background: rgb(26, 46, 161);
  96. background-size: 100% 100% !important;
  97. }
  98. /* 用来设置当前页面element全局table 鼠标移入某行时的背景色*/
  99. .regulaContainer .el-table--enable-row-hover .el-table__body tr:hover>td {
  100. background-color: rgb(60, 10, 175) !important;
  101. /* color: #f19944; */
  102. /* 设置文字颜色,可以选择不设置 */
  103. }
  104. </style>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/113587
推荐阅读
相关标签
  

闽ICP备14008679号