要做到这种效果,打印界面和使用code128自动生成条形码

Js中调用调用打印和自动生成条形码Js中调用调用打印和自动生成条形码


首先在html页面中引入打印和条形码的js

<script src="jquery.PrintArea.js"></script>

<script src="jquery-barcode.js"></script>

在js中写弹出打印界面和生成条形码的代码

onPrint() {
    var self = this;
    var count = false;
$(".barcode").each(function() {
$(this).barcode(this.id, "code128", {
barWidth: 2,
barHeight: 40,
fontSize: 8
});
count = true;

});

                $("div#printArea").attr("style", "display:block");
$("div#printArea").printArea();

$("div#printArea").attr("style", "display:none");

}


我这里使用element循环生成条形码,所以在html中写的是

<template v-for="(material,index) in materials">
<tr>
<td colspan="1" align="center">{{code}}</td>
<td colspan="1" align="center">{{name}}</td>
<td colspan="1" align="center">
<div style="float: right;">
<div class="barcode" :id="code"></div>
</div>
</td>
</tr>
</template>


相关文章:

  • 2021-11-15
  • 2021-12-06
  • 2021-11-22
  • 2021-11-17
  • 2021-11-17
  • 2022-12-23
  • 2021-10-27
猜你喜欢
  • 2021-07-18
  • 2022-01-28
  • 2021-11-20
  • 2021-06-07
  • 2021-12-11
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案