要在Antd表格内添加子标题,需要使用Antd Table的扩展属性expandedRowRender
。下面是一个示例代码,其中expandedRowRender
将添加Description
字段及其值到表格的子行中。
import React from 'react';
import { Table } from 'antd';
const dataSource = [
{
key: '1',
name: 'Mike',
age: 32,
address: '10 Downing Street',
description: 'This is a description'
},
{
key: '2',
name: 'John',
age: 42,
address: '10 Downing Street',
description: 'This is another description'
}
];
const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name'
},
{
title: 'Age',
dataIndex: 'age',
key: 'age'
},
{
title: 'Address',
dataIndex: 'address',
key: 'address'
}
];
const expandedRowRender = record => (
{record.description}
);
const App = () => (
);
export default App;