继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

ajax 下载Excel 添加回调函数

野生安乃近
关注TA
已关注
手记 15
粉丝 7
获赞 38
this.$axios.get(this.$store.state.debug_server + '/operation/batchBind/exportErrorMac.do ?placeid=' + this.uploadParameter.placeid + '&batchid= ' + this.batchid,
{
responseType: "blob"
})
.then((response) => {
    // 转 字节流 为 excel  window.open("/operation/static/file/BatchImportDeviceMAC.xlsx");
    const url = window.URL.createObjectURL(new Blob([response.data]));
    const link = document.createElement('a');
    link.href = url;
    link.setAttribute('download', 'BatchImportDeviceMAC.xlsx'); //or any other extension
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link); //下载完成移除元素
    window.URL.revokeObjectURL(url); //释放掉blob对象 
    // 刷新 表格
    this.selectBatchPlaceBindNo();
})
.catch((error) => {
    console.log(error);
    this.$Message.error('未成功导出错误列表');
})

图片描述

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP