updateFile.vue 1.1 KB
Newer Older
B
update  
baiy 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
<template>
    <Upload style="display: inline-block" action="#" :before-upload="handleUpload" :format="format" :showUploadList="false">
        <Button shape="circle" icon="md-cloud-upload"/>
        <template v-if="!disablePaste">
            <pasteClipboardFlie v-if="type==='file'" @on-paste-file="handleUpload"/>
            <pasteClipboardFlie v-if="type==='image'" @on-paste-image="handleUpload"/>
        </template>
    </Upload>
</template>
<script>
import pasteClipboardFlie from './pasteClipboardFlie';

export default {
    components: {
        pasteClipboardFlie,
    },
    props: {
        disablePaste: {
            type: Boolean,
            default: false
        },
        type: {
            type: String,
            default: "file" // file,image
        }
    },
    computed: {
        format() {
            if (this.type === "image") {
                return ['jpg', 'jpeg', 'png']
            }
            return [];
        }
    },
    methods: {
        handleUpload(file) {
            this.$emit('success', file)
        }
    }
};
</script>