使用 :on-change=“handleChange” 来实现文件的覆盖
<el-upload
class="upload-demo"
action=""
:http-request="uploadPicture"
:on-preview="handlePreview"
:on-remove="handleRemoves"
:before-remove="beforeRemoves"
:on-error="imgUploadError"
:file-list="pictureList"
:on-change="handleChange"
list-type="xls"
:limit="2"
accept=".xlsx">
<el-button size="small" type="success" :loading="notUpload" style="width:220px;">点击上传</el-button>
</el-upload>
handleChange(file, fileList) {
if (fileList.length > 1) {
fileList[0] = fileList[1]
fileList.splice(1, 1);
}
},
使用Vue的el-upload组件处理文件上传及覆盖
文章讲述了如何在Vue应用中利用el-upload组件进行文件上传操作,特别是通过:on-change事件处理函数handleChange实现文件的覆盖逻辑,限制上传文件类型为.xlsx,并且限制最多只能上传2个文件。
1743

被折叠的 条评论
为什么被折叠?



