0
点赞
收藏
分享

微信扫一扫

【Flask从入门到精通:第十一课:逻辑外键、数据迁移】

yongxinz 2024-07-24 阅读 3
前端

1. 后端返回文件格式不是 utf-8

解决方案:后端加

 2. 若添加 utf-8 后依旧乱码  请求配置中添加 responseType: 'arraybuffer',

export function downMode() {
  return http.request({
    url: baseUrl + 'downTemplate',
    method: 'get',
    responseType: 'arraybuffer',
  });
}

下载

    const blob = new Blob([data]); // 接口返回的文件流
    const a = document.createElement('a');
    a.style.display = 'none';
    a.href = window.URL.createObjectURL(blob);
    a.download = fileName || 'mode.xlsx';
    a.click();
    window.URL.revokeObjectURL(a.href);
    a.remove();
举报

相关推荐

0 条评论