<template>
    <el-upload class="upload-demo" :action="$baseUrl + '/assets/uploadFile'"
        :on-success="onSuccess" :on-remove="onRemove">
        <el-button type="primary" v-if="!single || fileList.length===0">点击上传
        </el-button>
    </el-upload>
</template>

<script>
export default {
    name: "FileUpload",
    props: {
        single: {
            type: Boolean,
            default() {
                return false;
            }
        }
    },
    data() {
        return {
            fileList: []
        };
    },
    methods: {
        onSuccess(res, file, fileList) {
            this.fileList = fileList;
            this.$emit("input", res.data[0]);
        },
        onRemove(file, fileList) {
            this.fileList = fileList;
        }
    }
};
</script>

<style scoped>
</style>
