jquery-qrcode生成二维码

1、jquery-qrcodejavascript

  jquery-qrcode是一个为浏览器生成二维码的jquery插件。咱们很容易将它集成到咱们的应用。该插件也能够独立使用,也比较小。它是直接在客户端生成二维码生成。因此不会有图片的下载过程,必定程度上提升了系统性能。html

2、实例java

  一、jquery-qrcode下载地址为:https://github.com/dnspod/jquery-qrcode 。该包解压后有以下几个文件jquery

  二、开始编写程序git

    a、建立index.html文件,文件内容以下:github

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <title>basic example</title>
 5 </head>
 6 <body>
 7 <script src="jquery-1.10.2.min.js"></script>
 8  <script type="text/javascript" src="./src/jquery.qrcode.js"></script>
 9 <script type="text/javascript" src="./src/qrcode.js"></script>
10 <p>Render in table</p>
11 <div id="qrcodeTable"></div>
12 <p>Render in canvas</p>
13 <div id="qrcodeCanvas"></div>
14 <script> 
15     jQuery('#qrcodeTable').qrcode({
16         render    : "table",                <!--二维码生成方式 -->
17         text    : "http://www.baidu.com"  <!-- 二维码内容  -->
18     });    
19     jQuery('#qrcodeCanvas').qrcode({
20         text    : "http://www.baidu.com"
21     });    
22 </script>
23 </body>
24 </html>

 

  因为该插件使用到了jquery,因此咱们须要引入jquery的支持。生成的二维码也有两种方式,一种是使用网页table生成网页。另一种是直接使用canvas生成图片。canvas

相关文章
相关标签/搜索