element-ui中table表格row-style通过两列数据比较改变table tr行的背景色以及行样式失效问题

element-ui中table表格row-style通过两列数据比较改变table tr行的背景色以及行样式失效问题
<el-table v-loading=“loading” :data=“fixtureList” @selection-change=“handleSelectionChange” :max-height=“getHeight()” :row-style=“tableRowStyle” :row-class-name=“tableRowStyle1” size=“mini” border>

// 累计使用时长 >= 使用疲劳时间, 修改table tr行的背景色—行变色警告
方法1:
tableRowStyle({row,rowIndex}){
if(this.fixtureList[rowIndex].useCumulativeDuration >= this.fixtureList[rowIndex].fatigueDuration){
// return ‘color:red’; // 这样写无效,一个坑
let styleJson = {
“background”:"#ffa4a4"
};
return styleJson;
}
},
方法2:
tableRowStyle1({row,rowIndex}){
if(this.fixtureList[rowIndex].useCumulativeDuration >= this.fixtureList[rowIndex].fatigueDuration){
return ‘warning-row’
}
},

row-class-name / row-style / cell-class-name / cell-style这4个Table Attributes的详细使用,请看官网动手去试一下,实践出真知

<template> </div> <el-table :data=“tableData” border style=“width: 100%” class=“el-table”> <el-table-column fixed prop=“date” label=“日期” width=“150”> </el-table-column> <el-table-column prop=“name” label=“姓名” width=“120”> </el-table-column> <el-table-column prop=“province” label=“省份” width=“120”> </el-table-column> <el-table-column prop=“city” label=“市区” width=“120”> </el-table-column> <el-table-column prop=“address” label=“地址” width=“300”> </el-table-column> <el-table-column prop=“zip” label=“邮编” width=“120”> </el-table-column> <el-table-column fixed=“right” label=“操作” width=“100”> <template slot-scope=“scope”> <el-button @click=“handleClick(scope.row)” type=“text” size=“small”>查看</el-button> <el-button type=“text” size=“small”>编辑</el-button> </template> </el-table-column> </el-table> </div> </template> <script> export default { data() { return { searchKeyword: ‘’,// 搜索关键词 tableData: [{ date: ‘2016-05-02’, name: ‘王小虎’, province: ‘上海’, city: ‘普陀区’, address: ‘上海市普陀区金沙江路 1518 弄’, zip: 200333 }, { date: ‘2016-05-04’, name: ‘王小虎’, province: ‘上海’, city: ‘普陀区’, address: ‘上海市普陀区金沙江路 1517 弄’, zip: 200333 }, { date: ‘2016-05-01’, name: ‘王小虎’, province: ‘上海’, city: ‘普陀区’, address: ‘上海市普陀区金沙江路 1519 弄’, zip: 200333 }, { date: ‘2016-05-03’, name: ‘王小虎’, province: ‘上海’, city: ‘普陀区’, address: ‘上海市普陀区金沙江路 1516 弄’, zip: 200333 }] } }, methods: { handleSearch() { // 执搜索逻辑 console.log(‘搜索内容:’, this.searchKeyword); // 实际开发中这里调用接口,传递 searchKeyword 进数据查询 }, handleClick(row) { console.log(row); } } }; </script> <style scoped lang=“scss”> } //底部背景 .el-table { background: transparent !important; color: white; } //表头背景 ::v-deep .el-table th{ background: #245c8d !important ; height: 10px !important; } //内背景 ::v-deep .el-table tr{ background: #245c8d !important ; height: 10px !important; } //表头字体颜色 ::v-deep .el-table thead{ color: white; } ::v-depp .el-table td,building-top .el-table th.is-leaf{ border-bottom: 2px solid #2C82BE !important; } // ::v-deep .el-table–enable-row-hover .el-table__body tr:hover>td{ // background-color: #245c8d !important; // } /* 修改鼠标悬浮效果 / .el-table tbody tr:hover > td { background-color: #000000 !important; / 新的高亮颜色 / cursor: pointer; / 更改光标形状 */ } </style>边框颜色,高度宽度、hover样式修改了但是无变化
03-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值