黄聪

论SEO对人类的重要性,请看我的博客:hcsem.com

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
const downloadRes = async (url, name) => {
                    let response = await fetch(url);
                    let blob = await response.blob();
                    let objectUrl = window.URL.createObjectURL(blob);
                    let a = document.createElement('a');
                    a.href = objectUrl;
                    a.download = name;
                    document.body.appendChild(a);
                    a.click();
                    setTimeout(function () {
                        document.body.removeChild(a);
                    }, 1000);
                };

                downloadRes('文件url', '文件名');

  

posted on 2022-02-18 12:46  黄聪  阅读(769)  评论(0编辑  收藏  举报