element-table表格中插入顏色塊顯示數(shù)據(jù)狀態(tài)的示例代碼
element-table表格中插入顏色塊顯示數(shù)據(jù)狀態(tài)
dom部分:
<el-table-column label="是否異常"> <template slot-scope="scope"> <div class="dcs_sf_red" v-if="scope.row.sfyc == 0"></div> <div class="dcs_sf_green" v-if="scope.row.sfyc == 1"></div> </template> </el-table-column>
data部分:
data [ { date: '00:00', mode: '固定模式', jhz: 120, sfyc: 0, sjz: 120, sfxy: 1, fkz: 110, cgfs: 1, }]
css部分
.dcs_sf_red{ margin-left: 30%; width: 6px; height: 6px; border-radius: 50%; background-color: #FE685D; } .dcs_sf_green{ margin-left: 30%; width: 6px; height: 6px; border-radius: 50%; background-color: #5DFE96; }
element-plus的表格固定列不變顏色的解決辦法
前言:有的行需要變顏色 所以我們用到了row-class-name方法 但是固定列沒有變顏色
<el-table :row-class-name="tableRowClassName">xxx</el-table> const tableRowClassName = (value) => { if (JSON.stringify(row.stopApplyType) != 'null') { console.log('停發(fā)') return 'error-row' } else { return '' } } <style> .el-table .error-row { --el-table-tr-bg-color: var(--el-color-error-light-9); } </style>
這樣是非常不美觀的 所以我看了一下固定列的css 綁定的class
然后我們在app.vue加入以下代碼
.el-table-fixed-column–left 是針對固定在左側(cè)的固定列
.el-table-fixed-column–right 是針對固定在右側(cè)的固定列
//紅色的 .el-table .error-row { --el-table-tr-bg-color: var(--el-color-error-light-9); } .el-table .error-row .el-table-fixed-column--left { background-color: #fef0f0; } .el-table .error-row .el-table-fixed-column--right { background-color: #fef0f0; }
這樣的話就變美觀了很多 解決問題!
到此這篇關(guān)于element-table表格中插入顏色塊顯示數(shù)據(jù)狀態(tài)的文章就介紹到這了,更多相關(guān)element-table表格內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Bootstrap Table快速完美搭建后臺(tái)管理系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了Bootstrap Table快速完美搭建后臺(tái)管理系統(tǒng)的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-09-09詳解webpack 配合babel 將es6轉(zhuǎn)成es5 超簡單實(shí)例
本篇文章主要介紹了詳解webpack 配合babel 將es6轉(zhuǎn)成es5 超簡單實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05JS如何生成一個(gè)不重復(fù)的ID的函數(shù)
這篇文章主要介紹了JS如何生成一個(gè)不重復(fù)的ID的函數(shù),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下2016-12-12