前端导出xlsx表

 let params = {
       xxx//参数
 };
	//blob流
		let blob = new Blob([res.data], {
          type: res.data.type,
        });
     //节点
        let download = document.createElement("a");
        let href = window.URL.createObjectURL(blob);
        //约定好的文件名,并做名称处理
        let name = res.headers["content-disposition"].split(";")[1];
        name = name.split("=")[1];
        name = name.split(".")[0];
        //兼容火狐
        name = decodeURI(name+".xlsx");
        console.log(name);
        download.download = name;
        download.href = href;
        download.style.display = "none";
        document.body.append(download);
        download.click();
        //清除节点
        document.body.removeChild(download);
        window.URL.revokeObjectURL(href);

完成

你可能感兴趣的:(前端,js,前端,typescript,javascript)