From f423e2156134c260e4e760adc9884ec2ce2bf5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 12:21:03 +0800 Subject: [PATCH] =?UTF-8?q?=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 4ab29ab3f..5eef94d9f 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -31,6 +31,10 @@ class Fileslistitem extends Component{ let newvalue=Base64.encode(value) let {discussMessage,coursesId}=this.props let file_id=discussMessage.id + let link = document.createElement('a'); + document.body.appendChild(link); + link.download = Base64.decode(newvalue); + let url="/files/"+file_id+"/histories.json" axios.get(url,{ params:{ @@ -39,21 +43,15 @@ class Fileslistitem extends Component{ }).then((result)=>{ if(result.data.attachment_histories.length===0){ - - let link = document.createElement('a'); - document.body.appendChild(link); link.href = result.data.url; - console.log(newvalue) - // link.download = Base64.decode(newvalue); + link.style.display = 'none'; + document.body.appendChild(link); + link.click(); //兼容火狐浏览器 // let evt = document.createEvent("MouseEvents"); // evt.initEvent("click", false, false); // link.dispatchEvent(evt); // document.body.removeChild(link); - link.style.display = 'none'; - link.setAttribute('download',result.data.title); - document.body.appendChild(link); - link.click(); // // window.location.href=result.data.url; // let url = window.URL.createObjectURL(new Blob([result.data.url])); // let link = document.createElement('a');