tachybase_todo/packages/client/src/schemas/upload/index.md

82 lines
1.4 KiB
Markdown
Raw Normal View History

2021-06-27 15:41:40 +08:00
---
title: Upload - 上传
nav:
title: 组件
path: /client
group:
order: 1
2021-07-08 14:21:18 +08:00
title: Schemas
path: /client/schemas
2021-06-27 15:41:40 +08:00
---
# Upload - 上传
2021-07-13 00:31:38 +08:00
## 节点树
<pre lang="tsx">
<Upload/>
</pre>
2021-06-27 15:41:40 +08:00
## 代码演示
### 上传
```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
);
};
```