源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

JS条形码(一维码)插件JsBarcode用法详解【编码类型、参数、属性】

  • 时间:2022-04-17 19:12 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JS条形码(一维码)插件JsBarcode用法详解【编码类型、参数、属性】
本文实例讲述了JS条形码插件JsBarcode用法。分享给大家供大家参考,具体如下: 这里介绍一下在GitHub生成条形码的js插件→JsBarcode 条码支持的有: [b]CODE128 [/b]  CODE128 (自动模式切换)   CODE128 A/B/C (强制模式) [b]EAN [/b]  EAN-13   EAN-8   EAN-5   EAN-2   UPC (A) [b]CODE39 ITF-14 MSI [/b]  MSI10   MSI11   MSI1010   MSI1110 [b]Pharmacode Codabar[/b] 代码:
<!DOCTYPE html>
<html>
 <head>
 <meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no" />
 <title></title>
 <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
 <script type="text/javascript" src="js/JsBarcode.all.js"></script>
 </head>
 <body>
 <svg id="svgcode"></svg>
 <!-- or -->
 <canvas id="canvascode"></canvas>
 <!-- or -->
 <img id="imgcode" />
 <script>
  $("#svgcode").JsBarcode('Hi!');//or JsBarcode("#svgcode", "Hi!");
  $("#canvascode").JsBarcode('Hello world!');//or JsBarcode("#canvascode", "Hello world!");
  $("#imgcode").JsBarcode("I'm huangenai!");//or JsBarcode("#imgcode", "I'm bwju!");
 </script>
 </body>
</html>
[img]http://files.jb51.net/file_images/article/201704/2017419111635802.png?2017319111738[/img] JsBarcode 我们还可以设置条码的一些属性(可设置属性详细介绍 链接:[url=https://github.com/lindell/JsBarcode/wiki/Options]https://github.com/lindell/JsBarcode/wiki/Options[/url])
<img />
<script>
JsBarcode("#imgcode", "123", {
 format: "CODE39",//选择要使用的条形码类型
 width:3,//设置条之间的宽度
 height:100,//高度
 displayValue:true,//是否在条形码下方显示文字
 text:"456",//覆盖显示的文本
 fontOptions:"bold italic",//使文字加粗体或变斜体
 font:"fantasy",//设置文本的字体
 textAlign:"left",//设置文本的水平对齐方式
 textPosition:"top",//设置文本的垂直位置
 textMargin:5,//设置条形码和文本之间的间距
 fontSize:15,//设置文本的大小
 background:"#eee",//设置条形码的背景
 lineColor:"#2196f3",//设置条和文本的颜色。
 margin:15//设置条形码周围的空白边距
});
</script>
[img]http://files.jb51.net/file_images/article/201704/2017419111742908.png?2017319111811[/img] GitHub:https://github.com/lindell/JsBarcode 条码生成器:http://lindell.me/JsBarcode/generator/ JsBarcode示例与设置:http://codepen.io/lindell/pen/mPvLXx?editors=1010 简单的JsBarcode演示:http://codepen.io/lindell/pen/eZKBdO?editors=1010 更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/908.htm]JavaScript图片操作技巧大全[/url]》、《[url=http://www.1sucai.cn/Special/502.htm]JavaScript切换特效与技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/826.htm]JavaScript图形绘制技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/472.htm]JavaScript查找算法技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/439.htm]JavaScript错误与调试技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/297.htm]JavaScript数据结构与算法技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/281.htm]JavaScript遍历算法与技巧总结[/url]》及《[url=http://www.1sucai.cn/Special/119.htm]JavaScript数学运算用法总结[/url]》 希望本文所述对大家JavaScript程序设计有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部