后台方法的参数必须是@RequestBody修饰的。

前台关键代码:

axios ( {
method : 'post',
url : api.exportPlayTime , // 请求地址
data : {
choose : type,
begindate : startDate,
enddate : endDate
},
responseType : 'arraybuffer',
observe: 'response',
} )
.then ( ( res ) => { const fileName = ""+filename+".xlsx"
let blob = new Blob([res.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
if ( 'download' in document.createElement ( 'a' ) ) { // 非IE下载
const elink = document.createElement ( 'a' )
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL ( blob )
document.body.appendChild ( elink )
elink.click ()
URL.revokeObjectURL ( elink.href ) // 释放URL 对象
document.body.removeChild ( elink )
} else { // IE10+下载
navigator.msSaveBlob ( blob, fileName )
} })
download(data) {
if (!data) {
return
}
let url = window.URL.createObjectURL(new Blob([data]))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', 'excel.xlsx') document.body.appendChild(link)
link.click()
},

最新文章

  1. VS2013中web项目中自动生成的ASP.NET Identity代码思考
  2. Git管理项目实例说明-记录和跟踪项目
  3. [ACM_模拟] ZJUT 1155 爱乐大街的门牌号 (规律 长为n的含k个逆序数的最小字典序)
  4. URAL 1097 Square Country 2 离散化
  5. apache common包下的StringUtils的join方法
  6. 关于xml的一些知识,DTD,XSD
  7. eclipse.ini配置eclipse的启动参数
  8. CI(-)框架结构
  9. 搭建实时同步data guard的最高可用-切换主备
  10. 调试经验--硬盘U菜
  11. perl的Getopt::Long和pod::usage ?
  12. 怎样看paper 最有效率
  13. Amazon新一代云端关系数据库Aurora(上)
  14. 手把手在Ubuntu上面安装Docker
  15. shell脚本--初识CGI
  16. (贪心 优先队列)P1090合并果子 洛谷
  17. js 面向对象的三大特性
  18. Could not write file: C:\......\.classpath
  19. a标签点击后,保证后来的样式
  20. 普通用户su 到root,无需密码方式,及iptables封掉本机某个端口,core文件配置

热门文章

  1. Python numpy tensorflow 中的 点乘 和 矩阵乘法
  2. 阿里云ubuntu 16.04 搭建pptpd 第二版
  3. hibernate关联关系一对多
  4. nginx学习(四):nginx处理web请求机制
  5. 【Excel】对比两列值
  6. WPF 精修篇 数据触发器
  7. 基础知识 Asp.Net MVC EF各版本区别
  8. 数位DP入门详解+题目推荐
  9. C#开发BIMFACE系列29 服务端API之获取模型数据14:获取图纸列表
  10. css 适配