依赖安装
npm install html2canvas
npm install jspdf
函数调用以及实现(vue)
// 引入
import html2canvas from 'html2canvas'
import JsPDF from 'jspdf'
const previewEl = document.getElementById('targetDom')
// 函数调用
this.savePdf(previewEl).then(res => {
})
// 函数实现
savePdf(html2canvasDom, downloadName = '下载文件') {
return html2canvas(html2canvasDom, {
// width: 1714,