{return imggreySuccess(file ,scope.row)}"multiple:limit=“3”:file-list=“fileLi_element http-r">
赞
踩
解决:通过http-request
<el-upload
class="upload-demo"
action=""
:headers="importHeaders"
:http-request="(file)=>{return imggreySuccess(file ,scope.row)}"
multiple
:limit="3"
:file-list="fileList"
>
<el-button size="small">
点击上传
</el-button>
<div slot="tip" class="el-upload__tip">
可上传多个附件,且每个附件不超过2M
</div>
methods: { imggreySuccess(params, row) { const isLt2M = params.file.size / 1024 / 1024 < 2 // 通过 FormData 对象上传文件 var formData = new FormData() formData.append('file', params.file) // formData.append('FileName', params.file.name) if (!isLt2M) { this.$message.error('请上传2M以下的文件') return false } // 设置header this.importHeaders['X-AUTH-TOKEN'] = Cookies.get('X-AUTH-TOKEN') // token this.upLoadData.fileType = `winBidNoticeAttachment_${row.typecode}`// 文件类型 axios.post(`${this.upLoadFileUrl}${createURL(this.upLoadData)}`, formData, { headers: { 'X-AUTH-TOKEN': Cookies.get('X-AUTH-TOKEN') }}) .then(function(res) { }) .catch(function(err) { console.error(err) }) // 校验是否每条数据至少有一条数据 数据整理 // const fileObj = Object.assign(file) // this.fileLists = this.performanceData // this.fileLists.map(item => { // if (item.typecode === row.typecode) { // this.arrBuff.push(fileObj) // item.arr = this.arrBuff // return // } // }) } }
就解决上传传参的问题。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。