zoukankan      html  css  js  c++  java
  • Element upload 组件实现自定义上传功能

    <el-form-item label="照片">
      <el-upload
        v-if="operType !== 'details'"
        ref="upload"
        class="upload-demo"
        accept='.jpg,.png'
        :action="`${httpConfig.hashUrl}/sys/core/file/upload.do`"
        :show-file-list="false"
        :before-upload="beforeAvatarUpload"
        :on-success="handleAvatarSuccess"
        :http-request="uploadFile">
        <el-button size="small" type="primary">点击上传</el-button>
        <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
      </el-upload>
      <img style=" 200px" v-if="imageUrl" :src="imageUrl" class="avatar">
      <span v-if="!imageUrl && operType === 'details'">--</span>
    </el-form-item>
    async uploadFile(files) { try { var formData = new FormData(); formData.append("file", files.file); formData.append("types", "Image"); formData.append("id", files.file.uid); formData.append("name", files.file.name); formData.append("type", files.file.type); formData.append("lastModifiedDate", files.file.lastModifiedDate); formData.append("size", files.file.size); formData.append("from", 'SELF'); const { data } = await fileUpload(formData) this.form.photo = data[0].fileId } catch (error) { } },
  • 相关阅读:
    [POI2011]Lightning Conductor
    [NOI2009]诗人小G

    公告&留言板
    联合省选 2020 题解
    年末时的一些思维碎屑
    RE:ゼロから始める AFO 生活
    退役前的做题记录6.0
    2019年湖南省大学生计算机程序设计竞赛 (HNCPC2019) 简要题解
    300iq Contest 1 简要题解
  • 原文地址:https://www.cnblogs.com/fczbk/p/14439634.html
Copyright © 2011-2022 走看看