js实现文件下载
<a href="./files/standard/01.pdf" name="信息安全技術" id="dwo">點擊下載</a>
function downfile(url, name = "") {const aEle = document.createElement("a");document.body.appendChild(aEle);aEle.setAttribute("href", url);aEle.setAttribute("download", name);aEle.click();document.body.removeChild(aEle);
}
const btn = document.getElementById("dwo");
btn.addEventListener("click", () => {downfile("./files/standard/01.pdf", "test");
}, false)
?
總結(jié)
- 上一篇: vue项目打包之后放在服务器上测试的时候
- 下一篇: 计算机中的主存储器有哪些