el-upload组件限制上传个数
element上传文件需要限制上传个数,结合limit和:on-exceed去处理。
<el-upload ref="upload" :action="uploadUrl()" multiple :limit="5" :on-preview="handlePreview" :on-remove="handleRemove" :file-list="fileList" :on-success="uploadSuccess" :on-exceed="masterFileMax" :before-remove="beforeRemove"> <el-button size="mini">上传附件</el-button> </el-upload>
methods: { masterFileMax(files, fileList) { console.log(files, fileList); this.$message.warning(`请最多上传 ${this.limit} 个文件。`); } }