我在 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();
}
原文由 aszymkiw 发布,翻译遵循 CC BY-SA 4.0 许可协议
vue-html2pdf
npm 模块无法正常工作。而不是你可以尝试html2pdf
将 html 转换为 pdf 的模块vuejs
。包链接: https ://www.npmjs.com/package/html2pdf.js/v/0.9.1
代码沙盒示例: https ://codesandbox.io/s/xlnzq7y28q
希望,您的问题将得到解决。谢谢。