Ant Design Table 数据不显示问题:组件渲染和数据源配置
可能是因为 Ant Design 的 Table 组件需要通过 columns 和 dataSource 来渲染表格内容。你在描述中提到在 components.body 中渲染了 row,但没有提到 Table 组件的使用。因此,如果你想要显示 dataSource 中的 data,你需要在组件中添加 Table 组件,并正确设置 columns 和 dataSource 属性。
以下是一个示例代码:
import { Table } from 'antd';
const YourComponent = () => {
const dataSource = [
{
key: '1',
name: 'John Doe',
age: 30,
},
{
key: '2',
name: 'Jane Smith',
age: 25,
},
];
const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
},
];
return (
<div>
{/* other components */}
<Table columns={columns} dataSource={dataSource} />
</div>
);
};
export default YourComponent;
在上述代码中,我们创建了一个 Table 组件,并传递了 columns 和 dataSource 属性。这样,表格就可以正确地显示 dataSource 中的 data 了。请确保你正确设置了 columns 属性,以匹配 dataSource 中的数据字段。
原文地址: https://www.cveoy.top/t/topic/o3Y7 著作权归作者所有。请勿转载和采集!