Skip to content

Commit d077f39

Browse files
authored
feat: 添加dragDirectory拖拽上传文件夹demo (#560)
1 parent f424d38 commit d077f39

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

docs/demo/dragDirectory.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: dragDirectory
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/dragDirectory.tsx"/></code>

docs/examples/dragDirectory.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* eslint no-console:0 */
2+
import React from 'react';
3+
import Upload from 'rc-upload';
4+
5+
const props = {
6+
action: '/upload.do',
7+
type: 'drag',
8+
directory: true,
9+
beforeUpload(file, fileList) {
10+
console.log('beforeUpload', file.name, fileList);
11+
},
12+
onStart: file => {
13+
console.log('onStart', file.name);
14+
},
15+
onSuccess(file) {
16+
console.log('onSuccess', file);
17+
},
18+
onProgress(step, file) {
19+
console.log('onProgress', Math.round(step.percent), file.name);
20+
},
21+
onError(err) {
22+
console.log('onError', err);
23+
},
24+
style: { display: 'inline-block', width: 200, height: 200, background: '#eee' },
25+
// openFileDialogOnClick: false
26+
};
27+
28+
const Test = () => {
29+
return (
30+
<div
31+
style={{
32+
margin: 100,
33+
}}
34+
>
35+
<div>
36+
<Upload {...props}>
37+
<a>开始上传</a>
38+
</Upload>
39+
</div>
40+
</div>
41+
);
42+
};
43+
44+
export default Test;

0 commit comments

Comments
 (0)