this.http.post(URL, p, {responseType: 'blob'}).then(res => { if (res.type === 'application/octet-stream') { loading.close(); var blob = new Blob([res], {type: res.type}); var downloadUrl = window.URL.createObjectURL(blob); var anchor = document.createElement("a"); anchor.href = downloadUrl; // 默认代开乱码是正常的,用户知道自己所需的格式去更改扩展名 anchor.download = "default.txt"; anchor.click(); window.URL.revokeObjectURL(blob); } else { loading.close(); } });