赞
踩
<div style="float: right;display: inline-block"> <form class="form-horizontal upload-block" id="upload"> <el-upload class="upload-demo" ref="upload" action="/api/features/upload" :limit="1" accept='.xlsx' :on-success="uploadSuccess" :on-error="uploadError"> <el-button size="small" type="primary" style="float: right;margin-left:10px;" class="taskBtn">点击上传</el-button> <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>--> </el-upload> </form> </div>
javascript
//文件上传事件 uploadSuccess(res) { console.log(res); this.$refs.upload.clearFiles(); //去掉文件列表 this.$message({ //弹窗 message: 'Excel导入成功', type: 'success', center: true, duration: 1000 }); }, uploadError(res){ console.log(res); this.$refs.upload.clearFiles(); //去掉文件列表 this.$message({ //弹窗 type: 'error', message: 'Excel导入失败!', center: true, duration: 1000 }); }