elementui 上传文件或是图片自定义按钮上传 都要关闭原本的上传事件
:auto-upload="false"
通过按钮调用接口 上传的请求头要设置为form
this.$http.post(
'/proxyApi/接口',
formDatas,
{'Content-type' : 'multipart/form-data'}
).then( (res) => {} )
// proxyApi代理
formDatas是上传的文件,通过elementui的on-change获取到文件
:on-change="handleEditChange"
handleEditChange(file, fileList) {
let formDatas = new FormData();
this.fileList.forEach(item => {
formDatas.append('file', item.raw)
})
},