上传附件——单页面

上传附件——单页面

效果

在这里插入图片描述

代码

index.vue

<el-form-item
              v-if='fileListIsShow'
              label='上传附件'
              >
    <el-upload
               :file-list='fileList'
               :http-request='uploadFile'
               :limit='1'
               :on-exceed='exceed'
               :on-remove='handleRemove'
               accept='.pdf, .jpg,.bmp,.png, .doc, .xls, .pptx,.xlsx'
               action='#'
               class='upload-demo'
               >
        <el-button size='small'>
            <i class='el-icon-upload2 el-icon--right'></i>上传附件
        </el-button>
        <template #tip>
<div class='el-upload__tip'>
    支持扩展名: pdf 、jpg、bmp、png、doc、xls、pptx、xlsx
    大小限制 2M
            </div>
        </template>
    </el-upload>
</el-form-item>

<script>
        const state = reactive({
                fileList: [], //附件简历回显使用
                fileListIsShow: true //选择短信时候内容和附件不显示
        });
        const fun = {
            disabledDate(time) {
                return time.getTime() < Date.now()
            },
            // 移除附件
            handleRemove(file, fileList) {
            },
            exceed(file, fileList) {
                ElMessage.warning('最多允许上传一个文件');
            },
            //附件简历上传
            uploadFile: row => {
                let fd = new FormData();
                fd.append('file', row.file);
                fileUpload(fd).then((res: any) => {
                    state.fileList = [];
                    state.resumeParamsVO.url = res.data.path;
                    state.resumeParamsVO.fileName = res.data.fileName;
                    state.fileList.push({
                        name: res.data.fileName,
                        url: res.data.path
                    });
                    
                });
            }, 
        return {
            ...toRefs(state),
            ...fun
        };      
</script>
<style>
:deep(.upload-demo) {
    display: inline-block;
    margin-left: 10px;
}
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值