我正在尝试使用 jspdf 从 json 数据创建 pdf。但这导致了我无法理解的错误。请帮我解决这个问题。
Data:
fileDataSpecific = [{ Date: "01/Jan/2019",
ServerName: "prlhpcms01",
ServerRequest: "Front End License returned",
ServerStatus: "57 timed out",
Time: "01:03:32",
UserName: "root",
srno: 1 }]
displayColumns = [
{ "val": "srno", "col": "Sr. No." },
{ "val": "ServerName", "col": "Server Name" },
{ "val": "UserName", "col": "User Name" },
{ "val": "Date", "col": "Date" },
{ "val": "Time", "col": "Time" },
{ "val": "ServerRequest", "col": "Server Request" },
{ "val": "ServerStatus", "col": "Server Status" }];
我的功能:
PrintData() {
var pdfData = this.fileDataSpecific
var pdfCol = this.displayedColumns
var doc = new jsPDF()
var col = [], row = []
pdfCol.forEach(element => {
col.push(element.col)
});
pdfData.forEach(element => {
var tempArray = []
pdfCol.forEach(element1 => {
tempArray.push(element[element1.val])
});
row.push(tempArray)
tempArray = []
});
doc.autoTable(col, row);
doc.save('Test.pdf');
}
Error:
请有人帮忙!谢谢。