当前位置:   article > 正文

Element table 给表头添加斜线分隔_element表头斜线

element表头斜线

方法一:利用官方文档中 多级表头 + 自定义样式 实现

示例:

  • 自定义表格类名,防止污染全局样式,一定要定义 align 、 header-align  以及 :resizable="false"  防止 拖动改变 列宽度 产生 错位
  1. <template>
  2. <div class=''>
  3. <el-table class="group-two-bias-divide" stripe v-loading="loading" :data="tableList" border max-height="500px">
  4. <el-table-column label="集团" width="180" align="right" fixed="left" :resizable="false">
  5. <el-table-column label="营收类目" prop="proName" width="180" header-align="left" fixed="left" :resizable="false">
  6. <template #default="{ row }"><span style="padding-left: 1em;">{{ row.proName }}</span></template>
  7. </el-table-column>
  8. </el-table-column>
  9. <el-table-column label="集团一号" prop="companyOne" />
  10. <el-table-column label="集团二号" prop="companyTwo" />
  11. </el-table>
  12. </div>
  13. </template>
  14. <script setup>
  15. const loading = ref(false)
  16. const tableList = ref([
  17. {
  18. proName:'日实际收款',
  19. companyOne:394.09,
  20. companyTwo:3794.09
  21. },
  22. {
  23. proName:'月实际累计收款',
  24. companyOne:2394.09,
  25. companyTwo:233794.09
  26. },
  27. {
  28. proName:'年实际累计收款',
  29. companyOne:33394.09,
  30. companyTwo:356794.09
  31. }
  32. ]);
  33. </script>
  34. <style lang='scss' scoped>
  35. :deep(.el-table.group-two-bias-divide thead.is-group tr:first-of-type th:first-of-type){
  36. border-bottom: none;
  37. background: linear-gradient(360deg, #f4fcf9 0%, #E7F7F4 100%);
  38. // &::before{
  39. // content: "";
  40. // position: absolute;
  41. // width: 1px !important;
  42. // height: 190px;
  43. // top: 0 !important;
  44. // left: -5px !important;
  45. // background-color: grey;
  46. // opacity: 0;
  47. // display: block;
  48. // transform: rotate(284deg);
  49. // -webkit-transform-origin: top;
  50. // transform-origin: top;
  51. // }
  52. }
  53. :deep(.el-table.group-two-bias-divide thead.is-group tr:last-of-type th:first-of-type){
  54. background: linear-gradient(360deg, #F5FCFA 0%, #f4fcf9 100%);
  55. &::before{
  56. content: "";
  57. position: absolute;
  58. width: 1px !important;
  59. height: 200px !important;
  60. top: auto !important;
  61. left: auto !important;
  62. bottom: 0 !important;
  63. right: 0 !important;
  64. background-color: #d6d6d6;
  65. display: block;
  66. transform: rotate(298deg);
  67. transform-origin: bottom;
  68. }
  69. }
  70. </style>

方法二:利用 自定义表头 插槽 实现

示例:

  • 插槽 自定义类名 以及 设置  :resizable="false"  防止 拖动改变 列宽度 产生 错位
  1. <template>
  2. <div class=''>
  3. <el-table stripe v-loading="loading" :data="tableList" border max-height="500px">
  4. <el-table-column label="" prop="proName" width="180" fixed="left" :resizable="false">
  5. <template #header>
  6. <div class="group-bias-divide">
  7. <div class="top">集团</div>
  8. <div class="bottom">营收泪目</div>
  9. </div>
  10. </template>
  11. <template #default="{ row }">
  12. <span style="padding-left: 1em;">{{ row.proName }}</span>
  13. </template>
  14. </el-table-column>
  15. <el-table-column label="集团一号" prop="companyOne" />
  16. <el-table-column label="集团二号" prop="companyTwo" />
  17. </el-table>
  18. </div>
  19. </template>
  20. <script setup>
  21. const loading = ref(false);
  22. const tableList = ref([
  23. {
  24. proName: "日实际收款",
  25. companyOne: 394.09,
  26. companyTwo: 3794.09,
  27. },
  28. {
  29. proName: "月实际累计收款",
  30. companyOne: 2394.09,
  31. companyTwo: 233794.09,
  32. },
  33. {
  34. proName: "年实际累计收款",
  35. companyOne: 33394.09,
  36. companyTwo: 356794.09,
  37. },
  38. ]);
  39. </script>
  40. <style lang='scss' scoped>
  41. :deep(.group-bias-divide) {
  42. .top {
  43. text-align: right;
  44. padding-right: .5em;
  45. box-sizing: border-box;
  46. }
  47. .bottom {
  48. text-align: left;
  49. padding-left: 1em;
  50. box-sizing: border-box;
  51. &::before {
  52. content: "";
  53. position: absolute;
  54. width: 1px !important;
  55. height: 187px !important;
  56. top: auto !important;
  57. left: auto !important;
  58. bottom: 0 !important;
  59. right: 0 !important;
  60. background-color: #d6d6d6;
  61. display: block;
  62. transform: rotate(289deg);
  63. transform-origin: bottom;
  64. }
  65. }
  66. }
  67. </style>

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

闽ICP备14008679号