dev_forum
杨树明 6 years ago
parent 5690f0b21f
commit 2ac3c90841

@ -27,25 +27,7 @@ class Fileslistitem extends Component{
}) })
this.props.Settingtypes(discussMessage.id) this.props.Settingtypes(discussMessage.id)
} }
downloadfiles=(url)=>{
axios.get((url),{responseType: 'blob'}).then((response) => {
const blob = new Blob([response.data]);
const downloadElement = document.createElement('a');
const href = window.URL.createObjectURL(blob);
// const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
const string = response.headers['content-disposition'].split('=')[1];
downloadElement.href = href;
downloadElement.download = string;
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement) ;// 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
}).catch((error) => {
console.log(error)
});
}
showfiles=(value)=>{ showfiles=(value)=>{
let {discussMessage,coursesId}=this.props let {discussMessage,coursesId}=this.props
let file_id=discussMessage.id let file_id=discussMessage.id

Loading…
Cancel
Save