2021-09-17 00:18:50 +08:00
|
|
|
<template>
|
|
|
|
<el-table
|
|
|
|
:data="tableData"
|
|
|
|
style="width: 100%"
|
|
|
|
:row-class-name="tableRowClassName"
|
|
|
|
>
|
|
|
|
<el-table-column prop="date" label="Date" width="180" />
|
|
|
|
<el-table-column prop="name" label="Name" width="180" />
|
|
|
|
<el-table-column prop="address" label="Address" />
|
|
|
|
</el-table>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
tableData: [
|
|
|
|
{
|
|
|
|
date: '2016-05-03',
|
|
|
|
name: 'Tom',
|
|
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
date: '2016-05-02',
|
|
|
|
name: 'Tom',
|
|
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
date: '2016-05-04',
|
|
|
|
name: 'Tom',
|
|
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
date: '2016-05-01',
|
|
|
|
name: 'Tom',
|
|
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
tableRowClassName({ row, rowIndex }) {
|
|
|
|
if (rowIndex === 1) {
|
|
|
|
return 'warning-row'
|
|
|
|
} else if (rowIndex === 3) {
|
|
|
|
return 'success-row'
|
|
|
|
}
|
|
|
|
return ''
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
2021-09-17 15:27:31 +08:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.el-table .warning-row {
|
|
|
|
--el-table-tr-background-color: var(--el-color-warning-lighter);
|
|
|
|
}
|
|
|
|
.el-table .success-row {
|
|
|
|
--el-table-tr-background-color: var(--el-color-success-lighter);
|
|
|
|
}
|
|
|
|
</style>
|