axios在请求获取文件的时候需要在页面中显示下载进度,通过使用onDownloadProgress
来实现我们想要的效果。
axios.get('assets/liku.zip', {
responseType: 'arraybuffer',
onDownloadProgress: (progressEvent) => {
console.log('下载中')
let percentCompleted = Math.round(progressEvent.loaded * 100 / progressEvent.total)
console.log(progressEvent.lengthComputable)
console.log(percentCompleted)
}
}).then(resp => {
})