h5文件下载
2024-09-04 09:15:34
// type1
await getFile(fileUrl).then((res) => {
console.log('download',res);
let bFile = window.URL.createObjectURL(
new Blob([res])
)
this.download(bFile, this.viewData.file_name)
});
// type2
window.open(fileUrl)
// type3
setTimeout(() => {
let a = document.createElement("a");
let url = fileUrl; //下载url
let filename = "download";
a.href = url;
a.download = filename;
a.click();
}, 500);
// type4
setTimeout(() => {
let myFrame = document.createElement("iframe");
myFrame.src = fileUrl;
myFrame.style.display = "none";
document.body.appendChild(myFrame);
window.open(fileUrl);
}, 500);
// type5
let url = "fileurl" // 文件绝对路径
var a = document.createElement("a");
a.setAttribute("href", url);
a.setAttribute("target", "_blank");
let clickEvent = document.createEvent("MouseEvents");
clickEvent.initEvent("click", true, true);
a.dispatchEvent(clickEvent);
最新文章
- Matlab中^2和.^2的区别
- Server ran out of threads to serve requests. Consider raising the ThreadsPerChild setting
- VIM的配置文件(vimrc)在哪里?【Win7】
- 图文教程:手把手教你用U盘安装Ubuntu
- C++ 头文件系列 (algorithm)
- GLUT Trackball Demo
- Dynamics CRM2016 Update or Create parentcustomerid in Contact using web api
- WebUtils【MD5加密(基于MessageDigest)】
- IP网际协议
- 学号20175313 《Arrays和String单元测试》第八周
- luogu P1353 【[USACO08JAN]跑步Running】
- 【python】python为何多线程无法切换
- JSAP106
- AMD Cpu 性能分析
- Xcode下的中文乱码问题
- ThreadLocal 与 Synchronized区别
- SQL记录-PLSQL包
- ASP代码审计学习笔记 -4.命令执行漏洞
- 代码使用了php的包管理器composer,include到你的php脚本
- solr分词一:mmseg4j
热门文章
- [bzoj5418]屠龙勇士
- [bzoj1385]Division expression
- [bzoj3304]带限制的最长公共子序列
- 五、Zookeeper的Shell操作
- 在spring启动后执行代码
- 【POJ1845】Sumdiv【算数基本定理 + 逆元】
- CF1555F Good Graph
- PostgreSQL 数据库备份与还原
- C++ and OO Num. Comp. Sci. Eng. - Part 1.
- 蛋白质组DIA深度学习之谱图预测