此后,我也遇到了同样的问题。 1.用以下命令安装jsPDF和jspdf-autotable npm安装jspdf npm install --save @ types / jspdf npm install jspdf-autotable --save
generatedile(){
var columns = [
{title: "ID", dataKey: "id"},
{title: "Name", dataKey: "name"},
{title: "Country", dataKey: "country"},
];
var rows = [
{"id": 1, "name": "Shaw", "country": "Tanzania"},
{"id": 2, "name": "Nelson", "country": "Kazakhstan"},
{"id": 3, "name": "Garcia", "country": "Madagascar"},
];
// Only pt supported (not mm or in)
var doc = new jsPDF('p', 'pt');
doc.autoTable(columns, rows, {
styles: {fillColor: [100, 255, 255]},
columnStyles: {
id: {fillColor: 255}
},
margin: {top: 60},
addPageContent: function(data) {
doc.text("Header", 40, 30);
}
});
doc.save('table.pdf');
}
答案 0 :(得分:0)
您不应导入jspdf-autotable。试试这个
var jsPDF = require('jspdf');
require('jspdf-autotable');