vue2+element ui 中的el-table 选中当前行当前行变色的实现代码
作者:周bro
这篇文章主要介绍了vue2+element ui 中的el-table 选中当前行当前行变色的实现代码,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧
vue2+element ui 中的el-table 选中当前行当前行变色

<el-table class="eltable" ref="multipleTable" :data="tableData" style="margin-top: 50px;width: 100%;"
:row-class-name="tableRowClassName" @row-click="rowClick">
<el-table-column v-for="(item, index) in tableTitleList" :label="item.name" :key="index"
:prop="item.prop" :width="item.width" align="center">
</el-table-column>
</el-table>方法:
rowClick(row, column, event) {
console.log(row,column);
this.selectIndex = row.index;
},
// 行选中样式
tableRowClassName({
row,
rowIndex
}) {
row.index = rowIndex
if (rowIndex == this.selectIndex) {
return 'success-row';
}
},样式:
::v-deep .success-row {
background-color: #81D3F8 !important;
}补充:Vue+ELement UI el-table移入或选中某行时改变颜色
Vue+ELement UI el-table移入或选中某行时改变颜色
起因
出库按钮 置灰时,鼠标移入到表格的某行时,行背景颜色与按钮背景颜色会被覆盖住
最初颜色

实现效果
修改行背景颜色

<style>
/* 用来设置当前页面element全局table 选中某行时的背景色*/
.el-table__body tr.current-row>td{
background-color: #92cbf1!important;
color: #fff;
}
/*鼠标移入某行时的背景色*/
.el-table--enable-row-hover .el-table__body tr:hover > td {
background-color: #454545 !important;
/* color: #fff; */
}
</style>到此这篇关于vue2+element ui 中的el-table 选中当前行当前行变色的文章就介绍到这了,更多相关vue2 element ui el-table 选中当前行内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
