• el-upload 上传携带参数


    1、template:

    <el-upload
      class="upload-file-demo"
      action="上传的url"
      ref="uploadComp"
      :auto-upload="false" //禁止自动上传
      :show-file-list='true' //显示上传文件名
      :file-list="certificates2" //回显文件
      :before-upload="beforeUpload" //文件上传前
      :on-change="handlePictureCardPreview2" //文件改变的时候
      :on-success="handleAvatarSuccess2" //文件上传成功回调
      :on-exceed="handleExceed2" //文件限制上传
      :on-remove="handleRemove2" //文件删除
      :limit="1" //限制个数
      :disabled="loading"
      :data="uploadData" //上传携带的参数
      accept=".xls,.xlsx,.png,.jpe,.jpeg"
    >
      <el-button :loading="loading" class="upload_btn" size="small" type="primary">上传明细</el-button>
    </el-upload>

    2、script:

    // 文件上传 - 上传前
    beforeUpload(file, fileList) {
        this.uploadData = { tradeOrder: this.dataList.id }; //上传携带的参数名
        let promise = new Promise((resolve) => {
            this.$nextTick(function () {
                resolve(true);
            });
        });
        return promise;
    },
    // 文件上传 - 文件选中后上传
    handlePictureCardPreview2(file, fileList) {
        this.$refs.uploadComp.submit();
    },
    //文件上传 - 成功回调
    handleAvatarSuccess2(res, file, fileList) {
        // console.log(res);
    },
    // 文件上传 - 限制上传
    handleExceed2(files, fileList) {
        this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
    },
    // 文件上传 - 删除
    handleRemove2(file, fileList) {
        var that = this;
        fileList.forEach((item, index) => {
            that.certificate2.push(item.url);
        })
    },
  • 相关阅读:
    mysql改为mysqli几项注意
    修改链接服务器地址提高下载速度
    果然最适合码农的博客还是博客园
    mysql
    php 检测字符集
    Internet Download Manager has been registered with a fake Serial Number
    SVN图标不见了
    理解createTrackbar函数
    程序块结构
    数组初始化
  • 原文地址:https://www.cnblogs.com/moguzi12345/p/15210151.html
Copyright © 2020-2023  润新知