手记

ajax 下载Excel 添加回调函数

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('未成功导出错误列表');
})

0人推荐
随时随地看视频
慕课网APP