31 lines
584 B
Vue
31 lines
584 B
Vue
|
|
<script setup>
|
||
|
|
import Api from "../../api/index.js";
|
||
|
|
|
||
|
|
const {api} = defineProps({
|
||
|
|
api: {
|
||
|
|
type: Function,
|
||
|
|
default: Api.system.uploadFile,
|
||
|
|
}
|
||
|
|
});
|
||
|
|
const emits = defineEmits(['success']);
|
||
|
|
|
||
|
|
const beforeUpload = (file) => {
|
||
|
|
api(file).then(({data}) => {
|
||
|
|
emits('success', data);
|
||
|
|
});
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<template>
|
||
|
|
<a-upload @before-upload="beforeUpload" v-bind="$attrs">
|
||
|
|
<template #upload-button>
|
||
|
|
<slot name="upload-button"></slot>
|
||
|
|
</template>
|
||
|
|
</a-upload>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<style scoped lang="scss">
|
||
|
|
|
||
|
|
</style>
|