How to include external JavaScript library in reactjs

后端 未结 3 1892
不知归路
不知归路 2020-12-20 13:33

I would like to know how it\'s possible to include an external JavaScript library in a react project. For example, I would like to import the jspdf library : https://github.

3条回答
  •  轮回少年
    2020-12-20 14:34

    First of all, don't use the source file. Just npm install jspdf --save like any other package, and import it with var pdfConverter = require('jspdf');

    Secondly, you're missing a () in this line var doc = new pdfConverter.jsPDF('p','pt');

    Do something like this:

    var converter = new pdfConverter();
    var doc = converter.jsPDF('p', 'pt');
    

提交回复
热议问题