<el-container style="height: 100%"> <el-table :data="tableData" style="width: 100%"> <el-table-column prop="index" label="考核指标" width="150"></el-table-column> <el-table-column prop="ymatter" label="负责人" width="120"></el-table-column> <el-table-column prop="cycles" label="事项" ></el-table-column> </el-table> </el-container>tableData: [{ index: '能力服务健康度', ymatter: '能力保障团队', cycles: '保障上台能力的正常平稳运行' },如何将的正常和运行设置为i红色
时间: 2024-03-27 22:38:43 浏览: 67
您可以使用 `formatter` 属性来自定义表格列的格式化函数,并在这个函数中将需要设置为红色的文本使用 HTML 标签包裹起来,比如 `<span>` 标签,并给这个标签添加 `style` 属性来设置颜色。
以下是实现将 "正常" 和 "运行" 设置为红色的代码:
```
<el-container style="height: 100%">
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="index" label="考核指标" width="150"></el-table-column>
<el-table-column prop="ymatter" label="负责人" width="120"></el-table-column>
<el-table-column prop="cycles" label="事项">
<template slot-scope="scope">
<span :style="{ color: scope.row.cycles.includes('正常') ? 'red' : 'black' }">{{ scope.row.cycles }}</span>
<span :style="{ color: scope.row.cycles.includes('运行') ? 'red' : 'black' }">{{ scope.row.cycles }}</span>
</template>
</el-table-column>
</el-table>
</el-container>
```
在这个代码中,我使用了 `scope.row.cycles.includes()` 方法来判断表格中的 "事项" 是否包含 "正常" 或 "运行",如果包含,则将对应的文本设置为红色。我还使用了 `:style` 绑定来动态设置文本颜色,如果包含需要设置为红色的关键词,则将颜色设置为红色,否则设置为黑色。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.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)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>图书商城-图书列表</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <script src="https://cdn.bootcss.com/vue/2.5.16/vue.min.js"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> </head> <body> 0">
{{bk.bookName}} ¥{{bk.bookPrice}} <iframe src="footer.html" frameborder="0" scrolling="no" width="100%" height="245px"></iframe> <script src="/BookShopSystem_war/layui/layui.js"></script>这是完整的html代码,请结合你给出的分页功能整合出完整的代码
![](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)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)