参考链接:https://www.cnblogs.com/coconutGirl/p/12605562.html
/**
* 下载附件
*/
adjustExport(row){
console.log(row);
const params = {
adjustNo: row.auditPoint.influenceCustomer
}
adjustExport(params).then((res) => {
const filename = res.headers['content-disposition']
if (filename) {
const blob = new Blob([res.data]) //Blob {size: 3982, type: ""}
var downloadElement = document.createElement('a')
var href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = decodeURIComponent(
filename.split('filename=')[1]
)
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
} else {
this.$message.error('下载失败')
}
})
.catch((err) => {
console.log(err)
})
}
api.js文件
export function adjustExport(params){
return request({
url: 'xxxx/export',
method: 'get',
responseType: 'blob',
params
})
}
网友评论