网页端压缩解压缩插件JSZIP库的使用

mac2022-06-30  74

  JSZIP这个库支持在网页端生成zip格式的文件,  官方网站是:http://stuk.github.io/jszip/

  因为官方的API发生改变, 最新的DEMO如下:

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <script src="http://stuk.github.io/jszip/dist/jszip.js"></script> <script type="text/javascript" src="http://stuk.github.io/jszip-utils/dist/jszip-utils.js"></script> <!--[if IE]> <script type="text/javascript" src="http://stuk.github.io/jszip-utils/dist/jszip-utils-ie.js"></script> <![endif]--> <script src="http://stuk.github.io/jszip/test/jquery-1.8.3.min.js"></script> <script src="http://stuk.github.io/jszip/vendor/FileSaver.js"></script> </head> <body> <script> var imgData = "R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs="; 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"); }); </script> </body> </html>

 

作者: NONO 出处:http://www.cnblogs.com/diligenceday/ QQ:287101329 

转载于:https://www.cnblogs.com/diligenceday/p/5017949.html

相关资源:js-library:我是付果果,这里记录我的点滴,大家共同进步,欢迎star-源码
最新回复(0)