在Ant Design的AntTable组件中,可以通过自定义rowClassName属性来设置行的样式,但无法直接通过rowClassName来设置行边框。要实现设置行边框的效果,可以通过以下步骤解决:
import { Table } from 'antd';
import 'antd/dist/antd.css';
const rowStyle = (record, index) => {
// 根据需要自定义行边框的样式
return {
border: '1px solid #000',
};
};
完整的示例代码如下:
import React from 'react';
import { Table } from 'antd';
import 'antd/dist/antd.css';
// 定义数据源和列配置
const dataSource = [
{ key: '1', name: 'John', age: 32 },
{ key: '2', name: 'Mike', age: 28 },
{ key: '3', name: 'Lucy', age: 36 },
];
const columns = [
{ title: 'Name', dataIndex: 'name', key: 'name' },
{ title: 'Age', dataIndex: 'age', key: 'age' },
];
const rowStyle = (record, index) => {
// 根据需要自定义行边框的样式
return {
border: '1px solid #000',
};
};
const App = () => {
return (
);
};
export default App;
通过以上方法,你可以在AntTable组件中通过自定义rowClassName属性来设置行边框。