You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
993 B
42 lines
993 B
3 years ago
|
import { defineComponent, ref } from 'vue';
|
||
|
import { initDefaultProps } from '../_util/props-util';
|
||
|
import AjaxUpload from './AjaxUploader';
|
||
|
import type { RcFile } from './interface';
|
||
|
import { uploadProps } from './interface';
|
||
|
|
||
|
function empty() {}
|
||
|
|
||
|
export default defineComponent({
|
||
|
name: 'Upload',
|
||
|
inheritAttrs: false,
|
||
|
props: initDefaultProps(uploadProps(), {
|
||
|
componentTag: 'span',
|
||
|
prefixCls: 'rc-upload',
|
||
|
data: {},
|
||
|
headers: {},
|
||
|
name: 'file',
|
||
|
multipart: false,
|
||
|
onStart: empty,
|
||
|
onError: empty,
|
||
|
onSuccess: empty,
|
||
|
multiple: false,
|
||
|
beforeUpload: null,
|
||
|
customRequest: null,
|
||
|
withCredentials: false,
|
||
|
openFileDialogOnClick: true,
|
||
|
}),
|
||
|
setup(props, { slots, attrs, expose }) {
|
||
|
const uploader = ref();
|
||
|
|
||
|
const abort = (file: RcFile) => {
|
||
|
uploader.value?.abort(file);
|
||
|
};
|
||
|
expose({
|
||
|
abort,
|
||
|
});
|
||
|
return () => {
|
||
|
return <AjaxUpload {...props} {...attrs} v-slots={slots} ref={uploader} />;
|
||
|
};
|
||
|
},
|
||
|
});
|