1,從名字就可以看出來,這是允許為上傳處理進度的事件,他是axios的請求配置之一,
axios({
method: 'post',
url: this.uploadurl,
data: formData,
headers: {
'Content-Type': 'multipart/form-data' // 檔案上傳
},
//檔案上傳進度值
onUploadProgress: function(progressEvent) {
let complete = parseInt((progressEvent.loaded / progressEvent.total) * 100)
that.percent = complete
}
})
.then(data => {
if (data.code == 200 && this.percent==100) {
this.$message.info('上傳成功!')
this.fileList = []
this.spinning = false
this.intofloder(this.currentdir[this.currentdir.length - 1])
let that = this
//2秒后關閉上傳視窗
setTimeout(function(){
that.upvisible=false
},2000)
} else {
this.$message.info(data.message)
this.spinning = false
}
})
2,progress.loaded表示當前上傳的資料大小,progress.total表示整個要上傳的資料大小,拿到當前上傳資料的百分比后傳給Element的進度條組件就可以實作啦
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/341275.html
標籤:區塊鏈
