请求下载Excel文件

  HTTP({
      method: 'post',
      url: API.projectManage.popeProjectReportExport,
      data,//参数
      responseType: 'arraybuffer',
      timeout:600000 
    }).then(res => {
      const url = window.URL.createObjectURL(
        new Blob([res], {
          type:
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        })
      );
      const link = document.createElement('a');
      link.href = url;
      link.setAttribute(
        'download',
        intl.t(`项目查询{time}导出数据`,{
          time:moment().format('YYYYMMDDHHmm')
        }) 
      );
      document.body.appendChild(link);
      link.click();
      message.success(
        intl.t('导出成功')
      )
})

  

知识在于点滴积累
原文地址:https://www.cnblogs.com/XieYFwin/p/14479927.html