elementPlus的elTable自定义样式备用
发表于:2025-02-08 | 分类: 前端
字数统计: 353 | 阅读时长: 1分钟 | 阅读量:
众所周知 在实际的页面开发时,所有表单表格都需要高度自定义。
这时如果每次来了新需求 再去使用 elementPlus 原生样式一点点改造就有点费劲,各种审查元素
所以为了让后续的开发不在这种繁琐的事情上耗费经历,在这里记录一下,后续直接拿来改对应的颜色就行
  • 首先是 html 部分,用 attr 给一组类名就行,对应下面的 css 类名,然后看情况加 highLight
    1
    2
    <el-table class="custom_el_table" header-cell-class-name="header_cell" highlight-current-row :data="tableData" style="width: 100%" height="100%">
    </el-table>
  • 其次就是封装的 scssless 文件内容了,例如把这个文件命名为 myElTable.scss

    👉注意 .current-rowbackground-image 是高亮行的背景图,如果较为简单可以用 css 处理
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    :deep(.current-row){
    background-image: url("/src/assets/images/table_row_active.png");
    background-size: 100% 100%;
    }
    :deep(.custom_el_table){
    background: transparent;
    --el-table-border: none;
    --el-table-row-hover-bg-color: rgba(0, 158, 250, .1) !important;
    --el-table-current-row-bg-color: rgba(0, 158, 250, 0) !important;
    --el-table-text-color: white;
    --el-table-header-bg-color: #041954;
    --el-table-bg-color: transparent;
    --el-table-tr-bg-color: transparent;
    --el-table-header-text-color: white;
    }
    :deep(.header_cell){
    font-size: 20px;
    font-weight: 500;
    }
    :deep(.el-table__inner-wrapper:before){
    height: 0;
    }
  • 最后在 vue 文件中的 style 里引入即可
    1
    @import '/src/assets/css/myElTable.scss';
  • 完事
上一篇:
cesium为entity添加跟随弹窗
下一篇:
处理拉取代码或者push时git提示Failed to connect to github.com port 443 after 21090 ms: Couldnt connect to server