多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## Html2Pdf 导出pdf 将长页面或元素节点导出为pdf文件 ![](https://img.kancloud.cn/1f/3e/1f3ecb2758b6dc3ecf8c44750ea67b36_488x433.png =200x) ### 代码示例 ```javascript <template> <div class="page"> <cvu-button type="primary" :loading="loading" @on-click="handleClick">导出pdf</cvu-button> </div> </template> <script> export default { data() { return { loading: false } }, methods: { handleClick() { this.loading = true this.$cvuHtml2Pdf({ class: '.page', fileName: 'html2pdf导出文件' }).then(() => { this.loading = false }) } } } </script> <style lang="scss" scoped> .page{ height: 100%; padding: 15px; box-sizing: border-box; } </style> ``` ### methods >[success] this.$cvuHtml2Pdf(options).then() - options: - id: 页面或元素节点id,如:'#page' - class:页面或元素节点class,如:'.page' - fileName:文件名称 - margin:内容边距