我在 vuejs 中有一个项目,我必须使用 vue-html2pdf。
当我在标签中写入文本时:<section>something</section>
,我的PDF生成了。
但是当我写标签时:<section><p>something</p></section>
,我的浏览器崩溃了。
这是我在 vuejs 中的代码:
<vue-html2pdf
:show-layout="false"
:preview-modal="true"
:paginate-elements-by-height="10"
:filename="test"
:pdf-quality="2"
:pdf-format="size"
:ref="ref"
>
<section slot="pdf-content">
<section class="pdf-item">
<img :src=url>
</section>
</section>
</vue-html2pdf>
还有我下载 PDF 的功能:
function generateReport() {
this.$refs.html2Pdf.generatePdf();
}
最佳答案
vue-html2pdf
npm 模块无法正常工作。而不是你可以尝试 html2pdf
模块在 vuejs
中将 html 转换为 pdf。
包裹链接:https://www.npmjs.com/package/html2pdf.js/v/0.9.1
Codesandbox 示例:https://codesandbox.io/s/xlnzq7y28q
希望您的问题能得到解决。谢谢。
https://stackoverflow.com/questions/60204249/