dev_forum
杨树林 5 years ago
parent 6486d59c6f
commit 80ca6bc9fe

@ -1419,12 +1419,14 @@ class Listofworks extends Component {
}else if(response.data.status&&response.data.status===-2){ }else if(response.data.status&&response.data.status===-2){
}else{ }else{
const type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' //excel文件 const type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' //excel文件
const blob = new Blob([response.data], { type: type }) const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a') const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob) const href = window.URL.createObjectURL(blob)
//后台再header中传文件名 //后台再header中传文件名
const name = decodeURI(response.headers['content-disposition'].split('=')[1]) const name = decodeURI(response.headers['content-disposition'].split('=')[1])
console.log(response.headers['content-disposition'].split('=')[1]);
console.log(name);
downloadElement.href = href downloadElement.href = href
downloadElement.download = name downloadElement.download = name
document.body.appendChild(downloadElement) document.body.appendChild(downloadElement)

Loading…
Cancel
Save