我能够导入jsPDF,但是我无法使用jspdf-autotable中的autoTable方法,不知道如何将它作为jsPDF的依赖项导入。如何在Angular 4中使用jspdf-autotable?
import { Injectable, Component } from '@angular/core';
import * as jsPDF from 'jspdf';
import { autoTable } from 'jspdf-autotable';
@Injectable()
export class PdfService {
constructor() {
}
convertJsonToPdf(columns: any, jsonData: any) {
var doc = new jsPDF('p', 'pt'); // OK, created
doc.autoTable(columns, jsonData); // Fails because autoTable is not in doc
}
}
尝试更换从 'jspdf-autotable' 这行'进口{autoTable};'与' import'jspdf-autotable';'; –
@SimonBengtsson它的工作,谢谢。 – user1916077