Bootstrap

vue前端上传下载进度条

export function export(data,download={}) {
  return request({
    url: '/common/upload',
    method: 'post',
    data: data,
    responseType:'blob',//此参数下载文件流时使用,可不加
    onDownloadProgress: (progressEvent)=> {
        download(progressEvent)
    },
  })
}

使用方法

let param={}
 export(param,showProgess).then(response => {
 })

//自定义一个函数用于接收
showProgess(progress){
  this.progressOpen = true
  this.progressLength =Math.round(progress.loaded / progress.total * 100)
 },
;