前端接收二进制文件流 下载文件的一次记录
let params = {}
const baseURL = HttpRequester.getUri();
let url_post = baseURL+ '/lithology/exportJltxpjExcel';
axios
.post(url_post, params, { responseType: 'arraybuffer' })
.then(res => {
let blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
if (window.navigator && window.navigator.msSaveBlob) {
window.navigator.msSaveBlob(blob, '文件.xls');
} else {
let link = document.createElement('a');
link.style.display = 'none';
let objectUrl = URL.createObjectURL(blob);
link.href = objectUrl;
link.download = this.fileName
link.click();
URL.revokeObjectURL(objectUrl);
}
})
.catch(err => {
this.$message.error(err.message);
});