elementui遇到的问题 ——el-table
el-table里设置表格单行样式无效
出现问题:
将tableRowClassName函数(代码中)的返回值赋给row-class-name;
但返回值设置无效,样式不生效

解决方法
在elementUI中,row-class-name、row-style、cell-class-name等属性要想生效必须使用全局class才能生效。
所以可以把想要的样式写在css文件里并引入main.js文件
<template>
<el-table
:data="tableData"
style="width: 100%"
:row-class-name="tableRowClassName">
</el-table>
</template>
<style>
.el-table .warning-row {
background: oldlace;
}
.el-table .success-row {
background: #f0f9eb;
}
</style>
<script>
export default {
methods: {
tableRowClassName({row, rowIndex}) {
if (rowIndex === 1) {
return 'warning-row'; //具体对应的样式的css文件要进入main文件
} else if (rowIndex === 3) {
return 'success-row';
}
return '';
}
},
data() {
}
}
</script>