Element-ui upload 的this.$refs.upload.submit();多文件上传为什么只提交一次

我用element-ui的自动上传模版创建的,有两个vue文件使用了这个上传模版,两个vue文件里基本上是一模一样的内容,但是我其中有一个vue里的this.$refs.upload.submit()只执行一次提交,我选取多个文件他只能上传第一个文件,但是另外一个vue里却能正常多个文件上传。

style="width: 195px;"       class="upload-demo1" ref="upload" :file-list="fileList"
    :on-preview="handlePreview" action :http-request="httpRequest" :auto-upload="false">
    <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
    <el-button style="margin-left: 10px;" size="small" type="success" :loading="isSending_register"
      @click="register('form')">上传到服务器</el-button>
    <div slot="tip" class="el-upload__tip1">选取文件后点击上传服务器上传文件(文件名不可含有空格和特殊符号)</div>
  </el-upload>
</el-form-item>
register(formName) {
  this.$refs[formName].validate(jojo => {
    if (jojo) {
      console.log("有效")
      console.log("文件列表:", this.$refs.upload.submit);
      this.$refs.upload.submit();
    } else {
      console.log("error submit!!");
      return false;
    }
  });
},
httpRequest(param) {
  this.isSending_register = true
  let fileObj = param.file; // 相当于input里取得的files
  let data = new FormData(); // FormData 对象
  data.append("file", fileObj); // 文件对象
  data.append("action", this.form.title);
  data.append("name", this.form.name);
  this.$axios.post('/vue/purchase_kanban/purchase_kanban_upload', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  }).then(res => {
    if (res.code == 200) {
      console.log("结果:", res);
      alert('上传成功')
    } else {
      alert('上传失败')
    }
    this.isSending_register = false
    this.purchase_kanban_filedata(this.form.title, this.form.name)
  }).console(error => {
    console.log("错误:", error);
    alert('发生错误:==' + error)
  });
},

测了一天了都没发现有什么不同,但就是行不通多个文件上传,到底是为什么?求解答

这是行不通的:

这是基本上一模一样的代码但是可以多个文件上传的:

评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值