📜  axios 下载 excel\file - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:22.399000             🧑  作者: Mango

代码示例1
axios({
  url: 'http://api.dev/file-download',
  method: 'GET',
  responseType: 'blob', // important
}).then((response) => {
   const url = window.URL.createObjectURL(new Blob([response.data]));
   const link = document.createElement('a');
   link.href = url;
   link.setAttribute('download', 'file.pdf'); //or any other extension
   document.body.appendChild(link);
   link.click();
});