ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

react+antd,Table表头文字颜色设置

react+antd,Table表头文字颜色设置

1、创建一个自定义的TableHeaderCell组件,并设置其样式为红色

const CustomTableHeaderCell = ({ children }) => (<th style={{ color: "red" }}>{children}</th>
);

2、将CustomTableHeaderCell组件传递到Table组件的columns属性中的title属性中:

const columns = [
{title: <CustomTableHeaderCell>列名</CustomTableHeaderCell>,dataIndex: 'data',key: 'key'},];

3、将数据源(dataSource)、列配置(columns)等相关信息传递给Table组件

<Table dataSource={dataSource} columns={columns} />;

返回列表