1.文档显示,table表格中有rowClassName属性
Table
参数 --------------------------------- 说明--------------------------------------------------------- 类型
2.vue页面使用
//template rowClassName
<a-table ref="table" :columns="columns" :dataSource="dataSource" :loading="loading"
:rowClassName='getRowBackGround' :pagination="ipagination"
:scroll="{x:true}" bordered size="middle" @change="handleTableChange" >
</a-table>
//script
<script>
export default {
data(){
return{
//表头
columns:[
{
title: "告警类型",
align: "center",
dataIndex: "typename",
scopedSlots: { customRender: "alarmType" }
}
]
}
},
methods:{
//根据条件table中customCell改变单元格样式
getRowBackGround(recordAlarm) {
// console.log("customCell改变单元格样式" + JSON.stringify(recordAlarm))
console.log("levelid------" + recordAlarm.levelid)
switch (recordAlarm.levelid) {//这里根据条件改变表格背景色
case "0":
return "table-color-default"
case "1":
return "table-color-success"
case "2":
return "table-color-processing"
case "3":
return "table-color-warning"
case "4":
return "table-color-error"
default:
return "table-color-default"
}
},
}
}
</script>
<style>
.table-color-success {
color: #ffffff;
background-color: #0c8fcf;
}
.table-color-processing {
background-color: #FFFF00;
}
.table-color-warning {
color: #ffffff;
background-color: #FFA500;
}
.table-color-error {
color: #ffffff;
background-color: #FF0000;
}
.table-color-default {
color: #ffffff;
background-color: #808080;
}
</style>