jsPDF-AutoTable“ doc.autoTable不是函数”

时间:2018-08-16 08:47:01

标签: javascript node.js jspdf pdfjs jspdf-autotable

我包括了必要的链接,但仍然给我错误。 错误

function pdfWrite() {
var doc = new jsPDF();
var columns = ["ID", "Name", "City"];
var rows = [
    [
        1, "Shaw", "Tanzania"
    ],
    [
        2, "Nelson", "Kazakhstan"
    ],
    [
        3, "Garcia", "Madagascar"
    ]
];

doc.autoTable(columns, rows)
doc.save('table.pdf');  
}

工作。

<script>
var doc = new jsPDF();
var columns = ["Bina ID", "Bina Adı", "Özellik"];
  var rows = [
     [
    1, "Shaw", "Tanzania"
     ],
     [
      2, "Nelson", "Kazakhstan"
     ],
     [
    3, "Garcia", "Madagascar"
     ]
  ];
   doc.autoTable(columns, rows)
    doc.save('table.pdf'); 
   </script>
在索引页上运行时

不会给出错误。文件中的函数调用时出错

1 个答案:

答案 0 :(得分:0)

您要导入jspdf-autotable吗?应该看起来像这样:

let jsPDF = require('jspdf');
require('jspdf-autotable');