ElementPlus表格中的背景透明

ElementPlus表格中的背景透明

最近写大屏,用到elementplus中的el-table,为了让显示效果好看一点,需要把表格的白色背景调整为透明,与整个背景融为一体。可以参考的资料非常少,大部分都是ElmentUI的方法,在某个前端开发群里问了一下解决方案,大佬给出的解决方案直接让我拍案叫绝,记录一下,以后翻起来更容易

直接上代码:

vue 复制代码
<template>
    <el-table :data="tableData" height="300" :row-style="rowstyle">
        <el-table-column v-for="(item, index) in tableForm" :key="index" :prop="item.prop" :label="item.label"
            show-overflow-tooltip></el-table-column>
    </el-table>
</template>

<script setup>
import { ref, onMounted, toRefs } from 'vue'
// import { getHighwayTrafficApi } from '@/apis/predictTraffic'

const tableForm = [
    { prop: 'road_name', label: '路名', width: 20 },
    { prop: 'section_desc', label: '堵点', width: 40 },
    { prop: 'speed', label: '速度', width: 20 },
    { prop: 'status', label: '状态', width: 20 },
    { prop: 'congestion_distance', label: '长度', width: 20 },
    { prop: 'congestion_trend', label: '趋势', width: 20 },

]

const props = defineProps({
    tableData: Array
})

const rowstyle = ({ row, rowIndex }) => {
    if (rowIndex % 2 === 0) {
        return {
            backgroundColor: 'rgba(3, 76, 106, 1)',
        }
    }
}

</script>

<style lang="scss" scoped>
.el-table {
    --el-table-border-color: transparent;
    --el-table-border: none;
    --el-table-text-color: #bdbdbe;
    --el-table-header-text-color: #bdbdbe;
    --el-table-row-hover-bg-color: transparent;
    --el-table-current-row-bg-color: transparent;
    --el-table-header-bg-color: transparent;
    --el-table-bg-color: transparent;
    --el-table-tr-bg-color: transparent;
    --el-table-expanded-cell-bg-color: transparent;
}
</style>

效果如下:

相关推荐
rockey6275 小时前
C#脚本引擎之AScript与Jurassic、Jint对比
javascript·c#·.net·js·script·动态脚本
lzhdim7 小时前
12、JavaScript常见的内存泄露问题 - JavaScript学习系列文章
开发语言·前端·javascript·学习·ecmascript
kyriewen10 小时前
我踩了3次同一个坑才明白:JavaScript里比0.1+0.2更隐蔽的5个数字陷阱
前端·javascript·面试
zhifou12345611 小时前
Vue基础(二)
前端·javascript·vue.js
默_笙11 小时前
🙃 我让爬虫终于看到了我的网站,后端同事说"这也行?"(下):App Router 全栈实战
前端·javascript
九九落12 小时前
JavaScript 实现北京时间精确到毫秒显示:UTC+8、Asia/Shanghai 与在线时间校准详解
开发语言·javascript·ecmascript
FEF前端团队12 小时前
小程序微信支付 V3 接入实战手册:从商户配置到前后端落地
javascript·后端·node.js
你脑门上的脚印13 小时前
Vue 项目从零实现语音转文字、文字转语音功能(完整可用 + 踩坑指南)
前端·vue.js
悟空瞎说14 小时前
# Dispatch(GCD)苹果官方文档 白话文讲解(Objective‑C 版本文档)
javascript
七牛开发者14 小时前
Coding Agent 如何跑稳长任务?从上下文管理到运行时状态
前端·javascript·后端