how to use jsPDF and jspdf-autotable in angular 5

后端 未结 10 856
北海茫月
北海茫月 2021-01-06 01:46

I am trying to use jsPDF and jspdf-autotable in my Angular 5.2.0 project. My package.json is below (related parts):

\"dependencies\": {
    ...
    \"jspdf\"         


        
10条回答
  •  走了就别回头了
    2021-01-06 02:33

    First you have declared .js files in styles property in angular-cli.json, you should add them to scripts. In the configuration that you have, you should add your jspdf scripts to scripts in angular-cli.json, So:

    "scripts": [ 
        "../node_modules/jspdf/dist/jspdf.min.js",
        "../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
      ],
    

    then you don't have to import any jspdf to your component. declare var jsPdf: any will be enough to use it.

提交回复
热议问题