要在 antd 表格中设置行之间的间距,可以通过自定义样式来实现。以下是一个示例代码:
import React from 'react';
import { Table } from 'antd';
import './App.css';
const dataSource = [
{
key: '1',
name: 'John Doe',
age: 25,
address: 'New York',
},
{
key: '2',
name: 'Jane Smith',
age: 30,
address: 'London',
},
// ... 更多数据
];
const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
},
{
title: 'Address',
dataIndex: 'address',
key: 'address',
},
];
const App = () => {
return (
);
};
export default App;
在上述代码中,我们使用了一个自定义的类名table-container
来包裹表格组件,并在 CSS 文件中设置了行之间的间距:
.table-container .ant-table-tbody > tr > td {
padding: 10px 0;
}
这里我们通过选择器.ant-table-tbody > tr > td
来选择表格中的单元格,并设置了上下方向的内边距为 10 像素。
将以上代码保存为一个组件并导入到你的应用程序中,你将看到 antd 表格中的行之间有了一定的间距。你可以根据需要调整间距的大小。