2017-09-20 13 views
1

jsPDFをインポートできましたが、jspPfの依存関係としてインポートする方法がわからないjspdf-autotableのautoTableメソッドを使用することはできません。上記の議論から抽出Angles 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 
    } 
} 
+1

試行で

import { autoTable } from 'jspdf-autotable'; 

を;'と ' import 'jspdf-autotable'; '; –

+0

@SimonBengtssonそれは働いた、ありがとう。 – user1916077

答えて

3

、このライン交換: 'jspdf-autotable' からこのライン `インポート{autoTable}を置換する

import 'jspdf-autotable'; 
+0

angle2についてはどうですか?どちらかをインポート 'jspdf - autotable';または{autoTable}を 'jspdf-autotable'からインポートします。何も動作していません – Deep

+0

'import 'jspdf-autotable';'は動作するはずです。それがあなたのために働かない場合は、より多くの情報を持つ新しい質問を書き留めてください。 –

+0

https://stackoverflow.com/questions/47344349/property-autotable-does-not-exist-on-type-jspdfこれは正確な質問です – Deep

関連する問題