2021-06-27 15:41:40 +08:00
|
|
|
---
|
|
|
|
title: Upload - 上传
|
|
|
|
nav:
|
|
|
|
title: 组件
|
|
|
|
path: /client
|
|
|
|
group:
|
|
|
|
order: 1
|
2021-07-04 00:19:26 +08:00
|
|
|
title: Components - 组件
|
|
|
|
path: /client/components
|
2021-06-27 15:41:40 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
# Upload - 上传
|
|
|
|
|
|
|
|
## 代码演示
|
|
|
|
|
|
|
|
### 上传
|
|
|
|
|
|
|
|
```tsx
|
|
|
|
import React from 'react';
|
|
|
|
import { Button } from 'antd'
|
|
|
|
import { UploadOutlined, InboxOutlined } from '@ant-design/icons'
|
|
|
|
import Upload from './';
|
2021-07-03 00:24:21 +08:00
|
|
|
import { SchemaRenderer, registerComponents } from '../';
|
2021-06-27 15:41:40 +08:00
|
|
|
|
|
|
|
const NormalUpload = (props) => {
|
|
|
|
return (
|
|
|
|
<Upload
|
|
|
|
{...props}
|
|
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
|
|
headers={{
|
|
|
|
authorization: 'authorization-text',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Button icon={<UploadOutlined />}>上传文件</Button>
|
|
|
|
</Upload>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
registerComponents({
|
|
|
|
NormalUpload,
|
|
|
|
});
|
|
|
|
|
|
|
|
const schema = {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
input: {
|
|
|
|
type: 'string',
|
|
|
|
title: `编辑模式`,
|
|
|
|
'x-decorator': 'FormItem',
|
|
|
|
'x-component': 'NormalUpload',
|
|
|
|
'x-reactions': {
|
|
|
|
target: 'read',
|
|
|
|
fulfill: {
|
|
|
|
state: {
|
|
|
|
value: '{{$self.value}}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
read: {
|
|
|
|
type: 'string',
|
|
|
|
title: `阅读模式`,
|
|
|
|
'x-read-pretty': true,
|
|
|
|
'x-decorator': 'FormItem',
|
|
|
|
'x-component': 'NormalUpload',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default () => {
|
|
|
|
return (
|
2021-07-03 00:24:21 +08:00
|
|
|
<SchemaRenderer schema={schema} />
|
2021-06-27 15:41:40 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
```
|