ReactJS中加入jspdf
背景
客户需要在前端将html转成pdf的功能,使用jspdf这个插件
版本
ReactJs 16.8.6
步骤
1.下载jspdf
npm install --save jspdf
2.导入jspdf和html2canvas
import * as jsPDF from 'jspdf';
import * as html2canvas from 'jspdf/node_modules/html2canvas'
window.html2canvas = html2canvas;//这里记得将html2canvas设为全局,不然后面找不到
3.调用.html()方法
let pdf = new jsPDF('p','pt',</