下载xlsx文件

  1. async function downloadFile() {
  2. let res = await axios.get(
  3. 'http://192.168.90.163:8301/application/excelTemplate/exportExcel?id=1504694990578782210',
  4. {
  5. headers: {
  6. Authorization: 'bearer d790f81a-3f12-426f-af0d-30a262307f30',
  7. },
  8. responseType: 'blob',
  9. },
  10. );
  11. res = res.data;
  12. let a = document.createElement('a');
  13. let url = URL.createObjectURL(res);
  14. a.href = url;
  15. a.setAttribute('download', '模板.xlsx');
  16. a.click();
  17. window.URL.revokeObjectURL(url);
  18. }