代码
<el-upload class="upload-box" action="" accept=".ppt,.pdf" :limit='1' :on-change="changeFile" ref="upload" :show-file-list="false" :auto-upload="false"> <el-button :type="form.otherInfo.length>0?'warning':'info'" slot="trigger">{{form.otherInfo.length>0?'重新上传':'点击上传'}}</el-button> <span>格式为ppt/pdf,其他资料小于20MB</span> </el-upload>
changeFile (file, fileList) { console.log('change', file, file.raw) if(file.raw.size>10*1024*1024){ this.$message.warning(`格式为pdf,报名表大小小于10M`) return } if (fileList.length > 0) { this.fileList = [fileList[fileList.length - 1]]//这一步,是 展示最后一次选择文件 } this.sendFile('pdf',file)//上传文件 this.$refs.upload.clearFiles(); //清空当前 files },
生效