想要的效果是 用户一次选择的文件一个接口上传完毕,但是element ui 里面是上传了多次一次一个文件的形式上传的

为4参数的接口调用了 多次执行的上传,我想上传一次 多个文件的 怎么实现呢?

因为element ui 里面的列表和我们的需求不一致 我重写了一个列表

class="upload-demo"

ref="upload"

drag

:data="Aobject"

:on-success="handleAvatarSuccess"

:auto-upload="false"

:before-remove="beforeRemove"

:show-file-list="false"

:on-change="handleChange"

:on-remove="handleRemove"

:action="actionUrl"

multiple

:on-exceed="onExceed"

:limit="limit"

>

将文件拖到此处,或点击上传
  • {{item.name}}

FileList 是用户每次选择文件的时候我push进去数据

handleChange(res, file){ //未上传,但是选择了文件触发

let Status=null;

this.TitleNameDisplay=true;

this.TitleName=res.name;

this.Arraya=file;

Status=this.wenjian(res.name);

if(res.status == "ready"){ //刚刚添加文件

this.FileList.push({

name:res.name.substring(0, res.name.lastIndexOf(".")),

status:Status,

wait:false,

Success:false

})

}

if(this.Name == null ||this.Name == undefined){

this.Name=this.FileList[0].name;

}

},

当用户提交的时候执行了

scuuse(){

this.Zhuan=true;

const _id=this.$route.query.id;

const _this=this;

for(var i=0;i

this.FileList[i].wait =true;

}

let promise = new Promise(function(resolve, reject) {

_this.actionUrl=`/chaoyang/api/dailyInfo/createDailyInfo/${_id}`;

_this.Aobject.name=_this.Name;//提交文件时候一并传递过 输入的标题文字

resolve();

});

promise.then(function() {

_this.$refs.upload.submit();

});

}

请问用element ui 怎么实现 一个接口上传多个文件呢?

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐