<el-upload
class="upload-demo"
:disabled="getBtn"
action="#"
accept=".pdf,.PDF" // 限制文件上传的格式
:before-upload="function(file,fileList){return beforeUpload(file,fileList,index)}"
:http-request="function(file,fileList){return uploadFile(file,index)}"
:on-preview="function(file,fileList){return handlePreview(file,index)}"
:on-success="function(file,fileList){return handSuccess(file,fileList,index)}"
:on-remove="function(file,fileList){return handleRemove(file,fileList,index)}"
:limit="999"
:file-list="item.assetAttributes.filter(el => el.attrType === 'PDF')" // 绑定的数组,因为我这个是多个模块都在一个数组内部,并且有些内容不是pdf文件,数据结构比较复杂,属于是数组里面包对象再包数组,所以需要过滤。
>
<el-button type="primary">上传文件</el-button>
<div slot="tip" class="el-upload__tip">只能上传pdf文件</div>
</el-upload>
初次上传数组为空。保存以后可正常反显
vue项目不同的模块使用同一个上传文件按钮
于 2023-10-11 15:44:13 首次发布