<template>
<el-table :data="tableData" style="width: 100%" :cell-style="tableCellStyle">
<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 setup>
const tableData = [
{
date: '2016-05-03',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
background: '#36bf36',
color: '#f8f8f8'
},
{
date: '2016-05-02',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
background: '#fa8072',
color: '#f8f8f8'
},
{
date: '2016-05-04',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
background: '#ff7f50',
color: '#222'
},
]
const tableCellStyle = ({ row, column }) => {
return { background: row.background, color: row.color };
};
</script>
<style></style>
vue3 element plus 自定义表格背景色
最新推荐文章于 2024-10-30 17:36:28 发布