Axios实现文件下载

axios.post(url, params, {
  method: 'post',
  responseType: 'blob'
}).then(res => {
  let url = window.URL.createObjectURL(new Blob([res.data]));
  let link= document.createElement('a');
  link.style.display='none';
  link.href=url;
  link.setAttribute('download', this.exportFilename);
  document.body.appendChild(link);
  link.click();
});

你可能感兴趣的:(Axios实现文件下载)