WishMeLz

生活其实很有趣

Vue axios返回文件流

responseType:"blob",  请求接口的时候加上
    
    let blob = new Blob([res], {
          type: "application/vnd.ms-excel",
        });
        let url = window.URL.createObjectURL(blob);
        let link = document.createElement("a");
        link.download = 'zz.xlsx'
        link.style.display = "none";
        link.href = url;
        document.body.appendChild(link);
        link.click();
        window.URL.revokeObjectURL(url);
        document.body.removeChild(link);