赞
踩
const downloadExcelFile = async function (api, params, name) { const res = await this.$get(api, params, { responseType: 'blob'}); try { let url = window.URL.createObjectURL(new Blob([res])) let link = document.createElement('a') link.style.display = 'none' link.href = url link.setAttribute('download', `${name}`) document.body.appendChild(link); link.click() //执行下载 window.URL.revokeObjectURL(link.href) //释放url document.body.removeChild(link) //释放标签 } catch (e) { this.$notify.error({ title: '错误', message: '下载文件失败' }); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。