如果已知有链接url的情况:
function fileDownload(filename, link) {
const a = document.createElement("a"), //创建a标签
e = document.createEvent("MouseEvents"); //创建鼠标事件对象
e.initEvent("click", false, false); //初始化事件对象
a.href = link; //设置下载地址
a.download = filename; //设置下载文件名
a.dispatchEvent(e); //给指定的元素,执行事件click事件
}
downloadFileList.forEach((file, index) => {
setTimeout(function () {
fileDownload(file.fileName, file.ossUrl);
}, 300 * index);
});
树下留言
LET’S TALK文字是一次相遇。很高兴听到你的声音。