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官方文檔即可