最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught ReferenceError: JSZip is not defined - Stack Overflow

programmeradmin1浏览0评论

I am looking to save a selected set of rows from a table. The saveAs function is giving me this Error: Uncaught ReferenceError: JSZip is not defined I have the FileSaver.js, I even updated it as in .js/blob/master/FileSaver.js

Can someone help me on what is wrong with this ? What could I do differently to have the rows exported to excel? I am using param query

              {                                                         
               type: 'button',
               label: "Export",
               icon: "ui-icon-arrowthickstop-1-s",

               listener: function () {

                   //filter the selected rows.
                   this.filter({
                       oper: 'replace',
                       data: [{ dataIndx: 'Selected', value: true, condition: 'equal' }]
                   })

                   Blob = this.exportData({

                       format: $("#export_format").val(),
                       zip: $("#export_zip").prop("checked"),
                       render: true
                   });

                   //reset the filter.
                   this.filter({
                       oper: 'replace',
                       data: []
                   })

                   if (typeof blob === "string") {
                       blob = new Blob([blob]);
                   }
                   saveAs(blob, "RollManager." + format);

               }
           }

I am looking to save a selected set of rows from a table. The saveAs function is giving me this Error: Uncaught ReferenceError: JSZip is not defined I have the FileSaver.js, I even updated it as in https://github./eligrey/FileSaver.js/blob/master/FileSaver.js

Can someone help me on what is wrong with this ? What could I do differently to have the rows exported to excel? I am using param query

              {                                                         
               type: 'button',
               label: "Export",
               icon: "ui-icon-arrowthickstop-1-s",

               listener: function () {

                   //filter the selected rows.
                   this.filter({
                       oper: 'replace',
                       data: [{ dataIndx: 'Selected', value: true, condition: 'equal' }]
                   })

                   Blob = this.exportData({

                       format: $("#export_format").val(),
                       zip: $("#export_zip").prop("checked"),
                       render: true
                   });

                   //reset the filter.
                   this.filter({
                       oper: 'replace',
                       data: []
                   })

                   if (typeof blob === "string") {
                       blob = new Blob([blob]);
                   }
                   saveAs(blob, "RollManager." + format);

               }
           }
Share Improve this question asked Apr 11, 2017 at 21:20 ForeverLearnerForeverLearner 1891 gold badge4 silver badges12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

You have to include JSZip script. It should be in your Paramquery files e.g. "/jsZip-2.5.0/jszip.min.js" like this

<script type="text/javascript" src="[path to paramquery]/jsZip-2.5.0/jszip.min.js"></script>

To import jszip in js, use require like this.

require(['<path-to js>/jszip'], function (JSZip) {
   console.log(JSZip);
   });

Pass JSZip wherever it is used.

发布评论

评论列表(0)

  1. 暂无评论