ant-design-vue/components/vc-upload/demo/beforeUpload.jsx

47 lines
1005 B
Vue
Raw Normal View History

2019-01-12 03:33:27 +00:00
import Upload from '../index';
2018-04-12 06:37:22 +00:00
export default {
2019-01-12 03:33:27 +00:00
render() {
2018-04-12 06:37:22 +00:00
const uploaderProps = {
props: {
2019-05-25 10:24:22 +00:00
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
2018-04-12 06:37:22 +00:00
multiple: true,
2019-01-12 03:33:27 +00:00
beforeUpload(file, fileList) {
console.log(file, fileList);
return new Promise(resolve => {
console.log('start check');
2018-04-12 06:37:22 +00:00
setTimeout(() => {
2019-01-12 03:33:27 +00:00
console.log('check finshed');
resolve(file);
}, 3000);
});
2018-04-12 06:37:22 +00:00
},
},
on: {
2019-01-12 03:33:27 +00:00
start(file) {
console.log('start', file, file.name);
2018-04-12 06:37:22 +00:00
},
2019-01-12 03:33:27 +00:00
success(file) {
console.log('success', file);
2018-04-12 06:37:22 +00:00
},
2019-01-12 03:33:27 +00:00
error(err) {
console.log('error', err);
2018-04-12 06:37:22 +00:00
},
},
2019-01-12 03:33:27 +00:00
};
2018-04-12 06:37:22 +00:00
return (
2019-05-26 05:58:06 +00:00
<div
style={{
margin: '100px',
}}
>
2018-04-12 06:37:22 +00:00
<div>
2019-01-12 03:33:27 +00:00
<Upload {...uploaderProps}>
<a>开始上传</a>
</Upload>
2018-04-12 06:37:22 +00:00
</div>
</div>
2019-01-12 03:33:27 +00:00
);
2018-04-12 06:37:22 +00:00
},
2019-01-12 03:33:27 +00:00
};