axios.get(url, {
  responseType: 'blob',
}).then(response => {
  const url = window.URL.createObjectURL(new Blob([response.data]));
  const link = document.createElement('a');
  Link.style.display = "none";
  let fname = '考勤导入模版.xlsx';
  link.href = url;
  link.setAttribute('download', fname);
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(Link); //下载完成移除元素
  window.URL.revokeObjectURL(url);
}).catch(error => {
  console.log('error:' + JSON.stringify(error))
});

axiost(
   method: 'get',
   url: url, // 请求地址
   data: options, // 参数
   responseType: 'blob' // 表明返回服务器返回的数据类型
).then(response => {
  const url = window.URL.createObjectURL(new Blob([response.data]));
  const link = document.createElement('a');
  Link.style.display = "none";
  let fname = '考勤导入模版.xlsx';
  link.href = url;
  link.setAttribute('download', fname);
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(Link); //下载完成移除元素
  window.URL.revokeObjectURL(url);
}).catch(error => {
  console.log('error:' + JSON.stringify(error))
});

Logo

前往低代码交流专区

更多推荐