2020-05-20 22:29:45 +08:00
|
|
|
---
|
2020-05-21 14:58:36 +08:00
|
|
|
order: 15
|
2020-05-20 22:29:45 +08:00
|
|
|
title:
|
2020-05-21 14:58:36 +08:00
|
|
|
zh-CN: 自定义进度条样式
|
2020-05-20 22:29:45 +08:00
|
|
|
en-US: Customize Progress Bar
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
2020-05-21 14:58:36 +08:00
|
|
|
使用 `progress` 属性自定义进度条样式。
|
2020-05-20 22:29:45 +08:00
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2020-05-21 14:58:36 +08:00
|
|
|
Use `progress` for customize progress bar.
|
2020-05-20 22:29:45 +08:00
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { Upload, message, Button } from 'antd';
|
|
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
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.`);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
progress: {
|
|
|
|
strokeColor: {
|
|
|
|
'0%': '#108ee9',
|
|
|
|
'100%': '#87d068',
|
|
|
|
},
|
|
|
|
strokeWidth: 3,
|
2020-05-21 14:58:36 +08:00
|
|
|
format: percent => `${parseFloat(percent.toFixed(2))}%`,
|
2020-05-20 22:29:45 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
<Upload {...props}>
|
2020-08-24 16:33:24 +08:00
|
|
|
<Button icon={<UploadOutlined />}>Click to Upload</Button>
|
2020-05-20 22:29:45 +08:00
|
|
|
</Upload>,
|
|
|
|
mountNode,
|
|
|
|
);
|
|
|
|
```
|