Axios实现文件下载

2020-04-27  本文已影响0人  陈yc
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();
});
上一篇 下一篇

猜你喜欢

热点阅读