//这是请求时的处理参数
xhrRequest({
url: "http://172.30.16.40:8123/api/bomplus?SAP_BillId=0400004143",
method: 'get',
headers: {
'Content-Type': 'application/json'
},
responseType: 'blob',
data: {},
})
.then(res => {
resolve(res);
})
.catch(err => {
reject(err);
});
//-------------------------
//这是文件流处理的代码
downloadFileNew: function (res) {
console.log(res);
if (res.status != 200) {
Message.error(decodeURIComponent(res.request.statusText));
return false;
} else {
let blob = new Blob([res.request.response], { type: res.headers['content-type'] });
let url = window.URL.createObjectURL(blob);
let a = document.createElement('a');
document.body.appendChild(a);
let fileName = res.headers['content-disposition'].split(';')[1].split('=')[1];
if (fileName[0] == '"') {
fileName = fileName.split('"')[1];
}
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
}
},
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |