前端下载excel文件

2022-07-26  本文已影响0人  Jycoding

try {

// new Blob([data])用来创建URL的file对象或者blob对象

  const url =window.URL.createObjectURL(new Blob([res.data], {type:'application/vnd.ms-excel;' }))

// 生成一个a标签

  const link =document.createElement('a')

link.style.display ='none'

  link.href = url

// 生成时间戳

  const timestamp =new Date().getTime()

link.download = timestamp +'数据'

  document.body.appendChild(link)

link.click()

}catch (error) {

console.error('download function error!', error)

}

https://blog.csdn.net/weixin_52497098/article/details/123279672

上一篇 下一篇

猜你喜欢

热点阅读