直接看代码:前端实现
<div class="upload"><el-uploadclass="upload-demo"name="upload_name":data="{'user_name':user_name}"action="http://localhost:8000/api/deal_pest_Image":show-file-list="false":on-success="handleSucess"><el-button size="small" type="primary">点击上传</el-button></el-upload>
</div>
注意data必须是object类型即键值对类型
处理成功的回调
handleSucess(response, file, fileList){console.log('response', response)if(response.code === 200){this.$message({message: '上传并处理成功',type: 'success'});this.init()}else {this.$message.error('出错了,请稍后重试');}
},