發(fā)起請求后處理blob類型返回值成json,處理報錯信息
.then((res) => {
// console.log(res);
if (res.type === 'application/json') {
const reader = new FileReader();
reader.readAsText(res, 'utf-8');
reader.onload = () => {
//處理報錯信息 JSON.parse(reader.result)拿到報錯信息
};
} else {
const binaryData = [];
binaryData.push(res);
const url = window.URL.createObjectURL(new Blob(binaryData, { type: 'application/pdf' }));
const iframe = window.open(url, title);
setTimeout(() => {
iframe.document.title = title;
iframe.print();
}, 500);
}
})
浙公網(wǎng)安備 33010602011771號