• js post下载文件 后端返回文件流


    // 导出excel
    handleExport = () => {
    const data = { ...this.state };
    data.keyword = this.keyword;
    Post({ url: "/projectInfo/exportProjectInfoList", data: data, type: "upload", responseType: "blob" }).then(res => {
    if (res.size != 88) {
    const content = res
    const blob = new Blob([content])
    const fileName = '项目信息表.xls'
    if ('download' in document.createElement('a')) { // 非IE下载
    const elink = document.createElement('a')
    elink.download = fileName
    elink.style.display = 'none'
    elink.href = URL.createObjectURL(blob)
    document.body.appendChild(elink)
    elink.click()
    URL.revokeObjectURL(elink.href) // 释放URL 对象
    document.body.removeChild(elink)
    } else {
    navigator.msSaveBlob(blob, fileName)
    }
    } else {
    message.error("该账号无导出项目权限", 0.5)
    }

    })
    }

  • 相关阅读:
    UVa532 Dungeon Master 三维迷宫
    6.4.2 走迷宫
    UVA 439 Knight Moves
    UVa784 Maze Exploration
    UVa657 The die is cast
    UVa572 Oil Deposits DFS求连通块
    UVa10562 Undraw the Trees
    UVa839 Not so Mobile
    327
    UVa699 The Falling Leaves
  • 原文地址:https://www.cnblogs.com/guidan/p/10402234.html
Copyright © 2020-2023  润新知