index.css:
.cell-class {
background-color: red;
}
import './index.css'
const column: Array<any> = {
title: "Age",
width: 100,
dataIndex: "age",
key: "age",
fixed: "left",
onCell: (record, index) => {
console.log("record, index: ", record, index);
// 单元格背景色添加过滤条件
if (record.age >= 32 && index % 2 === 0) {
return { className: "cell-class" };
}
return { className: "" };
}


本文介绍如何使用Ant Design的Table组件,通过onCell属性来动态设置表格中满足特定条件的单元格背景颜色,实现数据展示的个性化定制。

3399

被折叠的 条评论
为什么被折叠?



