前端用 js-file-download组件下载后端返回的pdf,word,excel文件

后端返回的pdf,word,excel的文件流导出需要让浏览器下载文件

1、安装js-file-download组件

html 复制代码
npm install js-file-download --save

2、在对应的页面引用

html 复制代码
import fileDownload from "js-file-download";

3、在接口返回结果后直接调用即可

html 复制代码
let data={
    id:processId,
    customerId:customerId
}
//后台导出文件接口
feeNotification(data).then(res => {
    //调用fileDownload即可
    fileDownload(res, 'xxxx.xlsx');
})
相关推荐
镜宇秋霖丶1 天前
2026.5.6@霖宇博客制作中遇见的问题
前端·javascript·vue.js
计算机专业码农一枚1 天前
微信小程序 uniapp+vue高校社团管理
vue.js·微信小程序·uni-app
小李子呢02111 天前
前端八股Vue---Vue-router路由管理器
前端·javascript·vue.js
洛_尘1 天前
Python 5:使用库
java·前端·python
Bigger1 天前
Bun 能上生产吗?我的实战结论
前端·node.js·bun
kyriewen1 天前
你的前端滤镜慢得像PPT?用Rust+WebAssembly,一秒处理4K图
前端·rust·webassembly
kyriewen111 天前
你等的Babel编译,够喝三杯咖啡了——用Rust重写的SWC,只需眨个眼
开发语言·前端·javascript·后端·性能优化·rust·前端框架
IT_陈寒1 天前
SpringBoot自动配置坑了我,原来要这样绕过去
前端·人工智能·后端
东方小月1 天前
Claude Code 完整上手指南:MCP、Skills、第三方模型配置一次搞定
前端·人工智能·后端
XZ探长1 天前
基于 Trae Solo 移动办公修复 Vue3 前端服务问题
前端