dev_forum
杨树明 5 years ago
parent f38091a59a
commit f9a2d94709

@ -27,6 +27,17 @@ class Fileslistitem extends Component{
}) })
this.props.Settingtypes(discussMessage.id) this.props.Settingtypes(discussMessage.id)
} }
downloadfiles=(url,name)=>{
const aLink = document.createElement('a');
document.body.appendChild(aLink);
aLink.style.display='none';
aLink.download =name;
aLink.href = url;
aLink.click();
document.body.removeChild(aLink);
}
showfiles=(value)=>{ showfiles=(value)=>{
let {discussMessage,coursesId}=this.props let {discussMessage,coursesId}=this.props
let file_id=discussMessage.id let file_id=discussMessage.id
@ -38,17 +49,7 @@ class Fileslistitem extends Component{
}).then((result)=>{ }).then((result)=>{
if(result.data.attachment_histories.length===0){ if(result.data.attachment_histories.length===0){
this.downloadfiles(result.data.url,filesname)
const aLink = document.createElement('a');
document.body.appendChild(aLink);
aLink.style.display='none';
const objectUrl = window.URL.createObjectURL(result.data.url);
aLink.href = objectUrl;
aLink.download =result.data.title;
aLink.click();
document.body.removeChild(aLink);
}else{ }else{
this.setState({ this.setState({
Showoldfiles:true, Showoldfiles:true,

Loading…
Cancel
Save