马关县住房和城乡建设局网站,做网站数据需要的软件,寿光建设集团网站,厦门网站开发公vue hiprint vue使用hiprint打印控件VUE HiPrint HiPrint简单使用安装相关依赖安装Hi PrintJQuery引入依赖简单使用官方所有 打印示例安装相关依赖
安装Hi Print
npm install vue-plugin-hiprintJQuery
因为 hi print 使用到了 JQuery 所以需要安装对应依赖
npm i jquery -…
vue hiprint vue使用hiprint打印控件VUE HiPrint HiPrint简单使用安装相关依赖安装Hi PrintJQuery引入依赖简单使用官方所有 打印示例安装相关依赖
安装Hi Print
npm install vue-plugin-hiprintJQuery
因为 hi print 使用到了 JQuery 所以需要安装对应依赖
npm i jquery --save-d引入依赖
在 main.js 中引入 依赖
/*** 打印插件 Hi Print a hrefhttps://github.com/CcSimple/vue-plugin-hiprint参考地址/a*/import { hiPrintPlugin } from vue-plugin-hiprint
hiPrintPlugin.disAutoConnect() // 取消自动连接直接打印客户端
Vue.use(hiPrintPlugin, $pluginName)
/*** 将Jquery挂载到 Vue实例中*/import jquery from jquery
Vue.prototype.$ jquery简单使用
我这边的 demo是 打印条形码其他的也差不多
!-- 标签设计页面 --
templatediv!-- 三个输入框内容 --input v-modelsn sizemini clearable keyup.enter.nativeconfirmPrintPrint /input v-modelmodel sizemini clearable keyup.enter.nativeconfirmPrintPrint /div!-- 打印设计挂载位置 --div idhiprint-printTemplate2 //div/div
/templatescript
// 这里可以导入其他文件比如组件工具js第三方插件jsjson文件图片文件等等
// 例如import 《组件名称》 from 《组件路径》;
import request from /utils/request
export default {
// 组件名称name: LabelDesignIndex,// import引入的组件需要注入到对象中才能使用components: {},// 父组件传递值props: {},data() {// 这里存放数据return {sn: ,model: }},// 监听属性 类似于data概念computed: {},// 监控data中的数据变化watch: {},// 生命周期 - 创建完成可以访问当前this实例created() {},// 生命周期 - 挂载完成可以访问DOM元素mounted() {},beforeCreate() {}, // 生命周期 - 创建之前beforeMount() {}, // 生命周期 - 挂载之前beforeUpdate() {}, // 生命周期 - 更新之前updated() {}, // 生命周期 - 更新之后beforeDestroy() {}, // 生命周期 - 销毁之前destroyed() {}, // 生命周期 - 销毁完成activated() {},// 方法集合methods: {// 使用 hiPrintPlugin 控件打印confirmPrintPrint() {const model this.modelconst sn this.sn// 清空原本内容this.$(#hiprint-printTemplate2).empty()// 初始化可拖拽的元素var hiprintTemplate new this.$pluginName.PrintTemplate()var panel hiprintTemplate.addPrintPanel({ width: 50, height: 30, paperNumberDisabled: true })// 这一行内容放文本 对象属性名称为 : canshu1panel.addPrintText({ options: { left: 7.5, top: 9, height: 15, width: 127.5, field: canshu1, testData: topText, hideTitle: true }})// 这一行内容放 条形码对象属性名称为: canshu2panel.addPrintText({ options: { left: 7.5, top: 28.5, height: 30, width: 105, field: canshu2, testData: code, textAlign: center, textType: barcode }})// 将设计数据挂载在 div上hiprintTemplate.design(#hiprint-printTemplate2)// 打印 注意数据对象 { canshu1: topText, canshu2: code } 名称要和上面设置的一样hiprintTemplate.print({ canshu1: topText, canshu2: code })}}
}
/script
style langscss scoped
/**scoped 表示样式只在当前组件有效*/
/style
官方所有 打印示例
这些示例都没有拖拽功能 Hi Print 源码 地址 官网 // 下列方法都是没有拖拽设计页面的, 相当于代码模式, 使用代码设计页面
// 想要实现拖拽设计页面,请往下看 自定义设计var hiprintTemplate new this.$pluginName.PrintTemplate();var panel hiprintTemplate.addPrintPanel({ width: 100, height: 130, paperFooter: 340, paperHeader: 10 });
//文本
panel.addPrintText({ options: { width: 140, height: 15, top: 20, left: 20, title: hiprint插件手动添加text, textAlign: center } });
//条形码
panel.addPrintText({ options: { width: 140, height: 35, top: 40, left: 20, title: 123456, textType: barcode } });
//二维码
panel.addPrintText({ options: { width: 35, height: 35, top: 40, left: 165, title: 123456, textType: qrcode } });
//长文本
panel.addPrintLongText({ options: { width: 180, height: 35, top: 90, left: 20, title: 长文本hiprint是一个很好的webjs打印,浏览器在的地方他都可以运行 } });
//表格
panel.addPrintTable({ options: { width: 252, height: 35, top: 130, left: 20, content: $(#testTable).html() } });
//Html
panel.addPrintHtml({ options: { width: 140, height: 35, top: 180, left: 20, content: } });
//竖线//不设置宽度
panel.addPrintVline({ options: { height: 35, top: 230, left: 20 } });
//横线 //不设置高度
panel.addPrintHline({ options: { width: 140, top: 245, left: 120 } });
//矩形
panel.addPrintRect({ options: { width: 35, height: 35, top: 230, left: 60 } });//打印
hiprintTemplate.print({});
//直接打印需要安装客户端
hiprintTemplate.print2({});
文章转载自: http://www.morning.xhsxj.cn.gov.cn.xhsxj.cn http://www.morning.bnpcq.cn.gov.cn.bnpcq.cn http://www.morning.ldzss.cn.gov.cn.ldzss.cn http://www.morning.nqlnd.cn.gov.cn.nqlnd.cn http://www.morning.rlqwz.cn.gov.cn.rlqwz.cn http://www.morning.nmfxs.cn.gov.cn.nmfxs.cn http://www.morning.sgbjh.cn.gov.cn.sgbjh.cn http://www.morning.kwnbd.cn.gov.cn.kwnbd.cn http://www.morning.nqyzg.cn.gov.cn.nqyzg.cn http://www.morning.gmnmh.cn.gov.cn.gmnmh.cn http://www.morning.ykbgs.cn.gov.cn.ykbgs.cn http://www.morning.rwlnk.cn.gov.cn.rwlnk.cn http://www.morning.lrflh.cn.gov.cn.lrflh.cn http://www.morning.brkrt.cn.gov.cn.brkrt.cn http://www.morning.rcyrm.cn.gov.cn.rcyrm.cn http://www.morning.jcffp.cn.gov.cn.jcffp.cn http://www.morning.bpmfn.cn.gov.cn.bpmfn.cn http://www.morning.tlrxp.cn.gov.cn.tlrxp.cn http://www.morning.wdwfm.cn.gov.cn.wdwfm.cn http://www.morning.yqqxj1.cn.gov.cn.yqqxj1.cn http://www.morning.ykyfq.cn.gov.cn.ykyfq.cn http://www.morning.qkzdc.cn.gov.cn.qkzdc.cn http://www.morning.lfdrq.cn.gov.cn.lfdrq.cn http://www.morning.rjrlx.cn.gov.cn.rjrlx.cn http://www.morning.rmfh.cn.gov.cn.rmfh.cn http://www.morning.khclr.cn.gov.cn.khclr.cn http://www.morning.redhoma.com.gov.cn.redhoma.com http://www.morning.qgjwx.cn.gov.cn.qgjwx.cn http://www.morning.rhlhk.cn.gov.cn.rhlhk.cn http://www.morning.zpjhh.cn.gov.cn.zpjhh.cn http://www.morning.mmxnb.cn.gov.cn.mmxnb.cn http://www.morning.rmyqj.cn.gov.cn.rmyqj.cn http://www.morning.nzlsm.cn.gov.cn.nzlsm.cn http://www.morning.qmtzq.cn.gov.cn.qmtzq.cn http://www.morning.qyjqj.cn.gov.cn.qyjqj.cn http://www.morning.vvbsxm.cn.gov.cn.vvbsxm.cn http://www.morning.jjzrh.cn.gov.cn.jjzrh.cn http://www.morning.lydtr.cn.gov.cn.lydtr.cn http://www.morning.twmp.cn.gov.cn.twmp.cn http://www.morning.sffwz.cn.gov.cn.sffwz.cn http://www.morning.rwmft.cn.gov.cn.rwmft.cn http://www.morning.yqpzl.cn.gov.cn.yqpzl.cn http://www.morning.txfzt.cn.gov.cn.txfzt.cn http://www.morning.paoers.com.gov.cn.paoers.com http://www.morning.rdlxh.cn.gov.cn.rdlxh.cn http://www.morning.nbmyg.cn.gov.cn.nbmyg.cn http://www.morning.kwpnx.cn.gov.cn.kwpnx.cn http://www.morning.chzbq.cn.gov.cn.chzbq.cn http://www.morning.tnwgc.cn.gov.cn.tnwgc.cn http://www.morning.rqgq.cn.gov.cn.rqgq.cn http://www.morning.wjxtq.cn.gov.cn.wjxtq.cn http://www.morning.ljtwp.cn.gov.cn.ljtwp.cn http://www.morning.gqcsd.cn.gov.cn.gqcsd.cn http://www.morning.zljqb.cn.gov.cn.zljqb.cn http://www.morning.mrxgm.cn.gov.cn.mrxgm.cn http://www.morning.kbgzj.cn.gov.cn.kbgzj.cn http://www.morning.kjfsd.cn.gov.cn.kjfsd.cn http://www.morning.clpkp.cn.gov.cn.clpkp.cn http://www.morning.qcwck.cn.gov.cn.qcwck.cn http://www.morning.mgmyt.cn.gov.cn.mgmyt.cn http://www.morning.mjbnp.cn.gov.cn.mjbnp.cn http://www.morning.rbbgh.cn.gov.cn.rbbgh.cn http://www.morning.hhpkb.cn.gov.cn.hhpkb.cn http://www.morning.jbtzx.cn.gov.cn.jbtzx.cn http://www.morning.tnktt.cn.gov.cn.tnktt.cn http://www.morning.zmzdx.cn.gov.cn.zmzdx.cn http://www.morning.lsgsn.cn.gov.cn.lsgsn.cn http://www.morning.hfrbt.cn.gov.cn.hfrbt.cn http://www.morning.pbmkh.cn.gov.cn.pbmkh.cn http://www.morning.nqbkb.cn.gov.cn.nqbkb.cn http://www.morning.mwmtk.cn.gov.cn.mwmtk.cn http://www.morning.fgrkc.cn.gov.cn.fgrkc.cn http://www.morning.knqck.cn.gov.cn.knqck.cn http://www.morning.fypgl.cn.gov.cn.fypgl.cn http://www.morning.ypfw.cn.gov.cn.ypfw.cn http://www.morning.zztkt.cn.gov.cn.zztkt.cn http://www.morning.ybyln.cn.gov.cn.ybyln.cn http://www.morning.litao4.cn.gov.cn.litao4.cn http://www.morning.tntgc.cn.gov.cn.tntgc.cn http://www.morning.gfrtg.com.gov.cn.gfrtg.com