element upload http-request
httpRequest: function(param) {
var that = this;
var form = new FormData();
form.append("file", param.file);
if (param.data) {
//TODO:附加信息
}
// that.$refs.upload.clearFiles();//
that.$http.post(param.action,form, {
headers: {
"Content-Type": "multipart/form-data"
},
onUploadProgress: progressEvent => {
let percent=(progressEvent.loaded / progressEvent.total * 100) | 0
//调用onProgress方法来显示进度条,需要传递个对象 percent为进度值
param.onProgress({percent:percent})
}
}).then((response)=>{
//上传成功 调用onSuccess方法,否则没有完成图标
//处理自己的逻辑
param.onSuccess();
})
参数param 包含了相应的上传处理函数,具体console.log(param)既可以查看相应的函数,对应ele官方文档即可