下面介绍两种下载方法,这两种方法都需要知道下载文件的 url.
- 第一种:a 标签下载
<a :href="url" :download="url" class="ground_pic" >下载 </a>
- 第二种:iframe 下载
const downloadIframe = document.querySelector(".download_iframe"); if (downloadIframe) { downloadIframe.src = url; } else { const iframe = document.createElement("iframe"); iframe.style.display = "none"; iframe.className = "download_iframe"; iframe.src = url; document.body.appendChild(iframe); }
标签:功能,url,前端,downloadIframe,iframe,download,document,下载 From: https://www.cnblogs.com/WuAnqi/p/16598802.html