生成条形码的js插件→JsBarcode
CODE128
CODE128 (自动模式切换)
CODE128 A/B/C (强制模式)
EAN
EAN-13
EAN-8
EAN-5
EAN-2
UPC (A)
CODE39
ITF-14
MSI
MSI10
MSI11
MSI1010
MSI1110
Pharmacode
Codabar
引用以下文件
<script src="http://www.jq22.com/jquery/vue.min.js"></script> <script src='js/JsBarcode.all.min.js'></script>
首先创建画布(或图像)
<svg id="barcode"></svg> <!-- or --> <canvas id="canvas"></canvas> <!-- or --> <img id="barcode"/>
简单的例子:
JsBarcode("#barcode", "Hi!"); // or with jQuery $("#barcode").JsBarcode("Hi!");
带有选项的示例:
JsBarcode("#barcode", "1234", { format: "pharmacode", lineColor: "#0aa", width:4, height:40, displayValue: false });
更高级的用例:
JsBarcode("#barcode") .options({font: "OCR-B"}) // Will affect all barcodes .EAN13("1234567890128", {fontSize: 18, textMargin: 0}) .blank(20) // Create space between the barcodes .EAN5("12345", {height: 85, textPosition: "top", fontSize: 16, marginTop: 15}) .render();