<template> <el-container style="height: 100%"> <el-table :data="tableData" style="width: 100%"> <el-table-column prop="date" label="考核指标"></el-table-column> <el-table-column prop="date" label="具体事项(原)"></el-table-column> <el-table-column label="具体事项(新)" prop="item"> <el-table-column prop="province" label="考核要点"></el-table-column> <el-table-column prop="city" label="计分方法"></el-table-column> <el-table-column prop="address" label="考核目标"></el-table-column> </el-table-column> <el-table-column prop="date" label="考核周期"></el-table-column> </el-table> </el-container> </template>如何将每个表头设置为不同的颜色
时间: 2023-10-11 13:08:24 浏览: 374
可以使用 `headerCellStyle` 属性来设置表头单元格的样式。例如,你可以在 `el-table-column` 标签中为每个表头单元格设置不同的背景色:
```html
<template>
<el-container style="height: 100%">
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="date" label="考核指标" header-style="{background:'#ff0000'}"></el-table-column>
<el-table-column prop="date" label="具体事项(原)" header-style="{background:'#00ff00'}"></el-table-column>
<el-table-column label="具体事项(新)" prop="item" header-style="{background:'#0000ff'}">
<el-table-column prop="province" label="考核要点"></el-table-column>
<el-table-column prop="city" label="计分方法"></el-table-column>
<el-table-column prop="address" label="考核目标"></el-table-column>
</el-table-column>
<el-table-column prop="date" label="考核周期" header-style="{background:'#ffff00'}"></el-table-column>
</el-table>
</el-container>
</template>
```
在上面的例子中,`headerStyle` 绑定了一个对象,该对象包含一个 `background` 属性,该属性指定了表头单元格的背景色。你可以根据需要修改 `background` 属性的值来设置不同的颜色。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044901.png)
![-](https://img-home.csdnimg.cn/images/20241231044901.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)