2020-12-15 17:09:52 +08:00
|
|
|
---
|
|
|
|
order: 10
|
|
|
|
title:
|
|
|
|
zh-CN: 限制数量
|
|
|
|
en-US: Max Count
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
通过 `maxCount` 限制上传数量。当为 `1` 时,始终用最新上传的代替当前。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Limit files with `maxCount`. Will replace current one when `maxCount` is `1`.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2020-12-15 17:09:52 +08:00
|
|
|
import { UploadOutlined } from '@ant-design/icons';
|
2022-05-23 14:37:16 +08:00
|
|
|
import { Button, Space, Upload } from 'antd';
|
|
|
|
import React from 'react';
|
2020-12-15 17:09:52 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2020-12-15 17:09:52 +08:00
|
|
|
<Space direction="vertical" style={{ width: '100%' }} size="large">
|
|
|
|
<Upload
|
|
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
|
|
listType="picture"
|
|
|
|
maxCount={1}
|
|
|
|
>
|
|
|
|
<Button icon={<UploadOutlined />}>Upload (Max: 1)</Button>
|
|
|
|
</Upload>
|
|
|
|
<Upload
|
|
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
|
|
listType="picture"
|
|
|
|
maxCount={3}
|
|
|
|
multiple
|
|
|
|
>
|
|
|
|
<Button icon={<UploadOutlined />}>Upload (Max: 3)</Button>
|
|
|
|
</Upload>
|
2022-04-03 23:27:45 +08:00
|
|
|
</Space>
|
2020-12-15 17:09:52 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2020-12-15 17:09:52 +08:00
|
|
|
```
|