打印指定HTML代码块,且支持设置打印文件页面大小。
import printMyHtmlJs from 'print-my-html-js'
Vue.use(printMyHtmlJs)
-
- custom:自定义打印样式
- default:默认打印样式(默认)
-
- start:左偏移(默认)
- center:水平居中
- end:右偏移
-
- start:上偏移(默认)
- center:纵向居中
- end:下偏移
-
- 210(默认:被打印Dom 宽度;单位:mm)
-
- 297(默认:被打印Dom 高度;单位:mm)
-
- 1(默认)
-
- default(不铺满)(默认)
- halfPaved(半页铺满)
- paved(铺满)
<div id="print" type="custom" printWidth="60" printHeight="40">
<div class="font-size: 20px;" style="color: red;">
我是要被打印的内容
</div>
</div>
<el-button v-print-html="'print'">打印</el-button>