ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] > [github](https://github.com/rndme/download) ## 安装 ``` npm install downloadjs bower install downloadjs require("downloadjs")(data, strFileName, strMimeType); ``` ## 下载文件重命名 ``` $.ajax({ url:url, success: download.bind(true, "text/html", "demo.exe") }); ``` or ``` var x=new XMLHttpRequest(); x.open( "GET", "/diff6.png" , true); x.responseType="blob"; x.onload= function(e){download(e.target.response, "awesomesauce.png", "image/png");}; x.send(); ``` ## 填入内容,并下载文件 ``` download("hello world", "dlText.txt", "text/plain"); ``` ## 下载文件或二进制流 ``` download("/robots.txt"); download("/diff6.png"); ```