Element-ui 文档上写:


template代码:
<el-table
:row-class-name="rowClassName"
:data="list"
@selection-change="selectionChange"
>
。。。。
selectionChange函数是要把选中的列表保存住,
rowClassName函数就是根据选中的索引来添加className
methods:{
selectionChange(val) {
// val是列表选中的数组信息
this.selectionList = val
},
rowClassName() {
//下面的意思就是列表索引为0的这行加一个className:warning-row,
if (rowIndex === 0) {
return 'warning-row';
}
}
},
<style>
.warning-row{
background: pink!important;
}
</style>
样式不能写在<style scoped>这里面,需要是<style>
根据个人需求自己修改就可以成功了。
网友评论