this.apiService.downLoadUrlList(value).subscribe((res: any) => {
if (res) {
const blob = new Blob([res]);
this.msg.success('正在下载……请稍等!');
const objectUrl = URL.createObjectURL(blob);
const a = document.createElement('a');
document.body.appendChild(a);
a.setAttribute('style', 'display:none');
a.setAttribute('href', objectUrl);
a.setAttribute('download', 'test.txt');
a.click();
// console.log(a.href);
URL.revokeObjectURL(objectUrl);
this.isLoading = false;
}
})
参考链接:https://www.cnblogs.com/xinjianheyi/p/10909820.html