<el-upload
class="upload-demo"
action=""
:on-change="handleChange"
:show-file-list="false"
:on-remove="handleRemove"
accept=".xls, .xlsx, .jpg, .png, .jpeg"
style="margin-left: 10px"
:auto-upload="false">
<el-button size="small" type="primary">上传附件</el-button>
</el-upload>
handleChange (_this, file) { // 上传函数
let params = new FormData()
params.append('file', file)
params.append('type', 2)
PostCheck.handleChange(_this, params)
}
// 通常饿了么自带的参数 file 传给后端就可以 如果后台需要base64 格式的 就把file转一下就好
// append 是向formData里添加数据 参数(后台需要的值)
file 就是要传给后台的文件流
params.append('file', file) 往 formData 对象里添加 值
比如 要给后台传俩个值 一个 file 一个 type 就直接 append 就行