mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-26 22:31:46 +08:00

* docs: add general components TS demo * docs: add layout components TS demo * docs: add navigation components TS demo * docs: add data entry components TS demo * chore(deps): add types for qs * docs: add data display TS demo * docs: add feedback components TS demo * docs: add other components TS demo * chore(deps): add types * docs: unified demo code style * docs: fix lint error * docs: add demo TS type * docs: fix demo TS type * test: update snapshot * docs: fix TS demo * feat: update Rate character type * docs: fix lint error * feat: update Rate character type * feat: update Rate character type
48 lines
1.0 KiB
Markdown
48 lines
1.0 KiB
Markdown
---
|
|
order: 0
|
|
title:
|
|
zh-CN: 点击上传
|
|
en-US: Upload by clicking
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
经典款式,用户点击按钮弹出文件选择框。
|
|
|
|
## en-US
|
|
|
|
Classic mode. File selection dialog pops up when upload button is clicked.
|
|
|
|
```tsx
|
|
import React from 'react';
|
|
import { Upload, message, Button } from 'antd';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import type { UploadProps } from 'antd';
|
|
|
|
const props: UploadProps = {
|
|
name: 'file',
|
|
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
|
|
headers: {
|
|
authorization: 'authorization-text',
|
|
},
|
|
onChange(info) {
|
|
if (info.file.status !== 'uploading') {
|
|
console.log(info.file, info.fileList);
|
|
}
|
|
if (info.file.status === 'done') {
|
|
message.success(`${info.file.name} file uploaded successfully`);
|
|
} else if (info.file.status === 'error') {
|
|
message.error(`${info.file.name} file upload failed.`);
|
|
}
|
|
},
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Click to Upload</Button>
|
|
</Upload>
|
|
);
|
|
|
|
export default App;
|
|
```
|