浏览器下载文件代码
this.$axios
.get(
this.$baseUrlsNew + 'xibei/monthlyanalysis/export?dataDate=' + this.search.dataDate,
{ responseType: 'blob' },
{
responseHeaders: {
'Access-Control-Expose-Headers': 'Content-Disposition'
}
}
)
.then((res) => {
var fileName = decodeURI(res.headers['content-disposition'].split('=')[1]);
var elink = document.createElement('a');
elink.download = fileName;
elink.style.display = 'none';
var blob = new Blob([res.data]);
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
document.body.removeChild(elink);
});
this.$axios
.post(this.$baseUrlsNew + 'xibei/monthlymeeting/export', this.imgData, {
headers: {
Authorization: 'Bearer ' + getSession('Authorization'),
'Content-Type': 'application/msword;charset=UTF-8 '
}
})
.then((res) => {
var elink = document.createElement('a');
elink.download = `西北区域公司--吉电股份安全生产工程${this.search.date.split('-')[1]}月份月度例会.doc`;
elink.style.display = 'none';
var blob = new Blob([res.data]);
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
document.body.removeChild(elink);
});