请使用react和antd写一个资源管理器组件
时间: 2024-05-05 14:18:51 浏览: 12
好的,我可以为您提供一份资源管理器组件的代码,使用react和antd库进行开发。以下是示例代码:
```jsx
import React from 'react';
import { Table, Button, Space } from 'antd';
const dataSource = [
{
key: '1',
name: '资源A',
type: '文件',
size: '10mb',
upload_date: '2021-07-01',
},
{
key: '2',
name: '资源B',
type: '文件夹',
size: '',
upload_date: '2021-07-01',
}
];
const columns = [
{
title: '名称',
dataIndex: 'name',
key: 'name',
},
{
title: '类型',
dataIndex: 'type',
key: 'type',
},
{
title: '大小',
dataIndex: 'size',
key: 'size',
},
{
title: '上传时间',
dataIndex: 'upload_date',
key: 'upload_date',
},
{
title: '操作',
key: 'action',
render: (_, record) => (
<Space size="middle">
<a>编辑</a>
<a>删除</a>
</Space>
),
},
];
const ResourceList = () => {
return (
<div>
<div style={{ marginBottom: '20px' }}>
<Button type="primary">上传</Button>
<Button type="primary" style={{ marginLeft: '10px' }}>新建文件夹</Button>
</div>
<Table dataSource={dataSource} columns={columns} pagination={{ pageSize: 5 }} />
</div>
);
};
export default ResourceList;
```
这份代码包含一个资源列表组件,用于展示已上传的资源,并提供了上传文件、新建文件夹等操作。请根据您的具体需求进行修改,如需帮助,请随时联系我。