vue項目里面預覽下載附件


    // 預覽附件
 handlePreview(file) { console.log(file); if (file.name.indexOf("txt") == "-1") { const link = document.createElement("a"); document.body.appendChild(link); link.style.display = "none"; link.setAttribute( "href", file.url + "?response-content-type=application/octet-stream" ); //設置下載文件的url地址
        link.target = "_blank"; document.body.appendChild(link); link.click(); document.body.removeChild(link); } else { let element = document.createElement("a"); element.setAttribute( "href", "data:text/plain;charset=utf-8," + file.url ); element.setAttribute("download", file.name); element.style.display = "none"; element.click(); } }

 ppt、pptx、doc、docx、pdf、xls、xslx、rar、txt、zip


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM