dev_forum
杨树明 5 years ago
parent 692216140b
commit fc354bc549

@ -35,27 +35,27 @@ class Fileslistitem extends Component{
params:{
course_id:coursesId
},
}).then((result)=>{
}).then((response)=>{
if(result.data.attachment_histories.length===0){
let link = document.createElement('a');
// link.href = window.URL.createObjectURL(new Blob([result.data.url]));
link.href = result.data.url;
link.download = result.data.title;
//兼容火狐浏览器
console.log(link)
document.body.appendChild(link);
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
link.dispatchEvent(evt);
document.body.removeChild(link);
response.blob().then(blob => {
const aLink = document.createElement('a');
document.body.appendChild(aLink);
aLink.style.display='none';
const objectUrl = window.URL.createObjectURL(blob.data.url);
aLink.href = objectUrl;
aLink.download =blob.data.title;
aLink.click();
document.body.removeChild(aLink);
});
}else{
this.setState({
Showoldfiles:true,
allfiles:result.data
})
}
// console.log(result)
}).catch((error)=>{
console.log(error)
})

Loading…
Cancel
Save