在 vueJS 上使用 PrintJS 打印页面部分 [英] Printing Page Section using PrintJS on vueJS
本文介绍了在 vueJS 上使用 PrintJS 打印页面部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用 npm install print-js --save
printJS
打印预览现在已成功显示,但问题在于它正在打印整个页面以及侧面板和滚动条.我是这样实现的:
<b-模态><div id="打印表单"><table style="border-collapse:collapse;宽度:100%"边框=1px">
当我点击打印时,它会打印整个页面,而不是由 id
指定的页面部分.有没有办法只打印特定的 div
内容?
解决方案
看起来您使用了错误的 ID.您是想改用 print-form
吗?
printJS({可打印:打印形式",类型:HTML"});
I have installed printJS
on my vue project using npm install print-js --save
Print Preview is now successfully displaying but the problem is that it is printing the whole page together with the side panel and the scroll bars. I have implemented it like this:
<template>
<b-modal>
<div id="print-form">
<table style="border-collapse: collapse; width: 100%" border="1px">
</table>
<button onclick="print()" class="btn btn-primary btn-block">Print</button>
</div>
</b-modal>
</template>
import * as Printjs from "print-js";
export default {
method: {
print() {
Printjs({
printable: "print-registration-form", //Id to print content
type: "HTML"
});
}
}
}
When I click print, it will print the whole page and not the page section specified by the id
. Is there a way I can only print the specific div
content?
解决方案
Looks like you are using the wrong id. Did you mean to use print-form
instead?
printJS({
printable: "print-form",
type: "HTML"
});
这篇关于在 vueJS 上使用 PrintJS 打印页面部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文