axios({
method: data.method,
url: `${data.url}`,
data: data.formObj,
headers: {
'Content-Type': 'application/json', // 设置请求头请求格式为JSON
'authentication': sessionStorage.getItem('token') // 设置token 其中K名要和后端协调好
},
responseType: 'blob'
}).then((res) => {
const link = document.createElement('a')
let blob = new Blob([res.data], {type: 'application/force-download'})
link.style.display = 'none'
link.href = URL.createObjectURL(blob)
let fileName = decodeURIComponent(res.headers['content-disposition']
.split(';')[1].split('filename=')[1])
.replace(/:/g, ':')
.replace('+', ' ')
link.download = data.fileName ? data.fileName : fileName // 下载的文件名
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}).catch(error => {
console.log(error)
// this.$Notice.error({
// title: '错误',
// desc: '网络连接错误'
// })
})