function downloadFile(res, name) {//下载文件
let blob = new Blob([res]); //创建一个blob对象
let a = document.createElement('a'); //创建一个<a></a>标签
a.href = URL.createObjectURL(blob); // response is a blob
a.download = name //文件名称 a.style.display = 'none';
document.body.appendChild(a);
a.click();
a.remove();
}
txt文件也可直接下载,不是直接打开页面。