ElementPlus表格中的背景透明

编程入门 行业动态 更新时间:2024-10-10 17:26:19

ElementPlus<a href=https://www.elefans.com/category/jswz/34/1768827.html style=表格中的背景透明"/>

ElementPlus表格中的背景透明

ElementPlus表格中的背景透明

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

直接上代码:

<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>

效果如下:

更多推荐

ElementPlus表格中的背景透明

本文发布于:2023-12-06 10:39:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1667322.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表格   透明   背景   ElementPlus

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!