mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
docs: fix demo typo
This commit is contained in:
parent
5447db9239
commit
7502d84d15
@ -7,11 +7,11 @@ title:
|
||||
|
||||
## zh-CN
|
||||
|
||||
`beforeUpload` 返回 `false` 或 `Promise.reject` 时,只用于拦截上传行为,不会阻止文件进入上传列表([原因](https://github.com/ant-design/ant-design/issues/15561#issuecomment-475108235)。如果需要阻止列表展现,可以参照此例配合 `onChange` 进行实现。
|
||||
`beforeUpload` 返回 `false` 或 `Promise.reject` 时,只用于拦截上传行为,不会阻止文件进入上传列表([原因](https://github.com/ant-design/ant-design/issues/15561#issuecomment-475108235))。如果需要阻止列表展现,可以参照此例配合 `onChange` 进行实现。
|
||||
|
||||
## en-US
|
||||
|
||||
`beforeUpload` only prevent upload behavior when return false or reject promise, the prevented file would still show in file list. Here is the example you can keep prevented files out of list by using `onChange`.
|
||||
`beforeUpload` only prevent upload behavior when return false or reject promise, the prevented file would still show in file list. Here is the example you can keep prevented files out of list by using `onChange`.
|
||||
|
||||
```jsx
|
||||
import React, { useState } from 'react';
|
||||
@ -22,13 +22,13 @@ const Uploader = () => {
|
||||
const [fileList, updateFileList] = useState([]);
|
||||
const props = {
|
||||
fileList,
|
||||
beforeUpload: (file) => {
|
||||
beforeUpload: file => {
|
||||
if (file.type !== 'image/png') {
|
||||
message.error(`${file.name} is not a png file`);
|
||||
}
|
||||
return file.type === 'image/png';
|
||||
},
|
||||
onChange: (info) => {
|
||||
onChange: info => {
|
||||
console.log(info.fileList);
|
||||
// file.status is empty when beforeUpload return false
|
||||
updateFileList(info.fileList.filter(file => !!file.status));
|
||||
@ -40,7 +40,7 @@ const Uploader = () => {
|
||||
<UploadOutlined /> Upload png only
|
||||
</Button>
|
||||
</Upload>
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
ReactDOM.render(<Uploader />, mountNode);
|
||||
|
Loading…
Reference in New Issue
Block a user