首页 > 移动平台 > 详细

axios导出 excel

时间:2018-12-20 17:37:44      阅读:282      评论:0      收藏:0      [点我收藏+]
this.axios({
  methods: ‘get‘,
  url: url,
  responseType: ‘blob‘
}).then(res => {
  const blob = new Blob([res])
  const fileName = ‘导出信息.xls‘
  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.clink()
    URL.revokeObjectURL(elink.href) // 释放URL 对象
    document.body.removeChild(elink)
  } else { // IE10+下载
    navigator.msSaveBlob(blob, fileName)
  }
})

 

axios导出 excel

原文:https://www.cnblogs.com/ToBeBest/p/10150571.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!