当前位置:   article > 正文

Vue使用axios处理后端数据流,导出excel_vue 3.+ 使用axio 请求返回流 转为 excel 文件

vue 3.+ 使用axio 请求返回流 转为 excel 文件

axios({

        method:'get',

        url:'url地址',

        responseType:'blob',

}).then(res=>{

        const link=document.createElement('a');

        let blob=new Blob([res.data],{type:'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})

        link.style.display='none',

        link.href=URL.createObjectURL(blob);

        link.downLoad='下载文件名',

        document.body.appendChild(link);

        link.click();

        document.body.removeChild(link)

}).catch(error=>{

        throw error;

})

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/770515
推荐阅读
相关标签
  

闽ICP备14008679号