需要用到两个插件:html2canvas
和 jsPDF
npm install html2canvas --save
npm install jspdf --save
import html2canvas from 'html2canvas';
import jsPDF from "jspdf";
// download()为下载按钮绑定的方法
download() {
// 下面的"print"为需要导出内容的id(把想导出的html内容用div包起来,加上id="print"即可)
html2canvas(document.getElementById("print")).