共计 2751 个字符,预计需要花费 7 分钟才能阅读完成。
1. 安装
npm install vue-plugin-hiprint
npm i socket.io-client –save // 为了静默打印(为此还需安装客户端)
2…html 页面 引入 css
3.main.js 引入或者按需应用
// 全局引用:import {hiPrintPlugin,defaultElementTypeProvider} from 'vue-plugin-hiprint'
Vue.use(hiPrintPlugin, '$pluginName')
Vue.use(defaultElementTypeProvider, '$defaultElementTypeProvider')
hiPrintPlugin.disAutoConnect(); // 取消自动连接直接打印客户端
import '@/assets/styles/hiprint.css' // 自定义 css
4。你要打印的页面引用
我的打印内容;{{item}}
5 安装客户端
https://gitee.com/CcSimple/electron-hiprint/releases
下载相应的客户端
安装打印客户端
如果要实现无预览打印 (静默打印) 就需要安装打印客户端, 无预览打印的原理是使用 hiprint 的打印客户端,它是一个基于 electron 的桌面应用,可以接收来自浏览器的打印请求,然后直接调用本地打印机进行打印。
安装地址:https://gitee.com/CcSimple/electron-hiprint/releases
问题
如果在配置客户端时遇到一下问题
解决方法
然后就可以使用啦!
补充
在使用客户端打印时如果我们的入口文件 index.html 中有这样的内容
在使用打印时会一同打印出来
解决方法 (在不动原代码的情况下最简单的方法)
参考地址
[1]: https://github.com/CcSimple/electron-hiprint
[2]: https://gitee.com/CcSimple/electron-hiprint
https://www.cnblogs.com/sexintercourse/p/17085140.html
https://mp.weixin.qq.com/s/4N4f7CkxodA-fuTJ_FbkOQ
https://developer.aliyun.com/article/1011031
原文地址: vue-plugin-hiprint 打印 预览打印 静默打印