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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM