jszip是一个用于创建、读取和编辑.zip文件的JavaScript库,且API的使用也很简单
链接
示例
var zip = new JSZip();
zip.file("Hello.txt", "Hello World\n");
var img = zip.folder("images");
img.file("smile.gif", imgData, {base64: true});
zip.generateAsync({type:"blob"})
.then(function(content) {
// see FileSaver.js
saveAs(content, "example.zip");
});
兼容性
Opera | Firefox | Safari | Chrome | Internet Explorer | Node.js |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |
Tested with the latest version | Tested with 3.0 / 3.6 / latest version | Tested with the latest version | Tested with the latest version | Tested with IE 6 / 7 / 8 / 9 / 10 | Tested with node.js 0.10 / latest version |
评论 (0)