ElementPlus表格中的背景透明解決方案
ElementPlus表格中的背景透明
最近寫大屏,用到elementplus中的el-table,為了讓顯示效果好看一點(diǎn),需要把表格的白色背景調(diào)整為透明,與整個(gè)背景融為一體??梢詤⒖嫉馁Y料非常少,大部分都是ElmentUI的方法,在某個(gè)前端開發(fā)群里問了一下解決方案,大佬給出的解決方案直接讓我拍案叫絕,記錄一下,以后翻起來更容易。
直接上代碼:
<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: '堵點(diǎn)', width: 40 },
{ prop: 'speed', label: '速度', width: 20 },
{ prop: 'status', label: '狀態(tài)', 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>效果如下:

補(bǔ)充:
elementPlus中el-table設(shè)置背景透明,修改底部邊框顏色
前提問題:表格設(shè)置背景透明,并且修改底部邊框顏色
解決過程:elementPlus中修改el-table背景和邊框樣式,第一使用deep,第二在el-table外層加一層div
解決結(jié)果:
html:
<div class="topTable">
<el-table :data="state.tableData" class="tableSpec" height="100%" >
<el-table-column prop="date" label="名稱" align="center" show-overflow-tooltip/>
<el-table-column prop="ss" label="次數(shù)" align="center"/>
<el-table-column prop="name" label="概率" align="center"/>
<el-table-column prop="address" label="總數(shù)" align="center"/>
<el-table-column prop="address" label="狀態(tài)" align="center" show-overflow-tooltip>
<template #default="scope">
<span style="color:#5AEE93">
{{ scope.row.address }}
</span>
</template>
</el-table-column>
</el-table>
</div>
css:
.topTable{
height: 70%;
margin: 0.05rem 0;
.tableSpec{
width: 100%;
--el-table-border-color: rgba(222, 253, 255, 0.16);
}
:deep(.el-table){
background-color: transparent;
}
:deep(.el-table__expanded-cell){
background-color: transparent;
}
:deep(.el-table th){
background-color: rgba(0, 238, 246, 0.08) !important;
color: #00FFFF;
font-size: 0.06rem;
}
:deep(.el-table tr){
background-color: transparent !important;
color: #FFFFFF;
}
:deep(.el-table td){
background-color: transparent !important;
}
.el-table__fixed::before{
background-color: transparent;
}
}
到此這篇關(guān)于ElementPlus表格中的背景透明的文章就介紹到這了,更多相關(guān)ElementPlus表格背景透明內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vxe-table?實(shí)現(xiàn)按回車鍵自動新增一行(示例代碼)
本文通過示例代碼介紹了vxe-table新版本中實(shí)現(xiàn)回車自動換行功能的方法,通過設(shè)置keyboard-config.isLastEnterAppendRow參數(shù)可以控制是否開啟該功能,當(dāng)回車鍵在最后一行按下時(shí),會自動新增一行,并將光標(biāo)移動到新行,代碼簡單易懂,感興趣的朋友跟隨小編一起看看吧2024-12-12
vue打包優(yōu)化時(shí)配置webpack的8大方案小結(jié)
vue-cli?生成的項(xiàng)目通常集成Webpack?,在打包的時(shí)候,需要webpack來做一些事情,這里我們希望它可以壓縮代碼體積,提高運(yùn)行效率,本文為大家整理了8大webpack配置方案,希望對大家有所幫助2024-02-02
vue項(xiàng)目之index.html如何引入JS文件
這篇文章主要介紹了vue項(xiàng)目之index.html如何引入JS文件問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12
如何在vue3中使用滑塊檢驗(yàn)vue-puzzle-verification
這篇文章主要介紹了在vue3中使用滑塊檢驗(yàn)vue-puzzle-verification的相關(guān)資料,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2023-11-11
vue項(xiàng)目npm?run?build打包dist文件及打包后空白解決辦法
npm run build 這個(gè)命令會執(zhí)行Vue CLI中預(yù)定義的打包配置,并將打包后的文件存放在"dist"文件夾中,這篇文章主要給大家介紹了關(guān)于vue項(xiàng)目npm?run?build打包dist文件及打包后空白的解決辦法,需要的朋友可以參考下2023-10-10
vue用elementui寫form表單時(shí),在label里添加空格操作
這篇文章主要介紹了vue用elementui寫form表單時(shí),在label里添加空格操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-08-08
vue實(shí)現(xiàn)動態(tài)路由的方法及路由原理解析
這篇文章主要介紹了路由原理及vue實(shí)現(xiàn)動態(tài)路由,Vue Router 提供了豐富的 API,可以輕松地實(shí)現(xiàn)路由功能,并支持路由參數(shù)、查詢參數(shù)、命名路由、嵌套路由等功能,可以滿足不同應(yīng)用程序的需求,需要的朋友可以參考下2023-06-06
element-ui表單提交自動清空隱藏表單值實(shí)現(xiàn)
這篇文章主要為大家介紹了element-ui表單提交自動清空隱藏表單值實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07

