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>

效果如下:

相关推荐
記億揺晃着的那天5 小时前
Vue + Element UI 表格自适应高度如何做?
javascript·vue.js·ui
GISer_Jing6 小时前
ByteDance——jy真题
前端·javascript·面试
真的想不出名儿6 小时前
Vue 中 props 传递数据的坑
前端·javascript·vue.js
阳光阴郁大boy6 小时前
星座运势网站技术解析:从零打造现代化Web应用
前端·javascript
sorryhc7 小时前
如何设计一个架构良好的前端请求库?
前端·javascript·架构
Queen_sy7 小时前
vue3 el-date-picker 日期选择器校验规则-选择日期范围不能超过七天
javascript·vue.js·elementui
lvchaoq7 小时前
react 修复403页面无法在首页跳转问题
前端·javascript·react.js
郝开7 小时前
6. React useState基础使用:useState修改状态的规则;useState修改对象状态的规则
前端·javascript·react.js
技术钱9 小时前
vue3 两份json数据对比不同的页面给于颜色标识
前端·vue.js·json
技术钱9 小时前
react+andDesign+vite+ts从零搭建后台管理系统(三)-Layout布局
javascript·react.js·ecmascript