First, Jquery-qrcode
Jquery-qrcode is a jquery plugin that generates two-dimensional code for a browser. It is easy for us to integrate it into our applications. The plug-in can also be used independently, but also relatively small. It is generated directly on the client side to generate the QR code. So there will not be a picture of the download process, to some extent, improve the system performance.
Second, examples
1, Jquery-qrcode is: Https://github.com/dnspod/jquery-qrcode. After the package decompression, there are several files
2. Start Writing Programs
A, create the index.html file, the file content is as follows:
1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <title>Basic example</title>5 </Head>6 <Body>7 <Scriptsrc= "Jquery-1.10.2.min.js"></Script>8 <Scripttype= "Text/javascript"src= "./src/jquery.qrcode.js"></Script>9 <Scripttype= "Text/javascript"src= "./src/qrcode.js"></Script>Ten <P>Render in table</P> One <DivID= "Qrcodetable"></Div> A <P>Render in Canvas</P> - <DivID= "Qrcodecanvas"></Div> - <Script> the JQuery ('#qrcodeTable'). QRCode ({ - Render:"Table", <!--Two-dimensional code generation method - - Text:"http://www.baidu.com" <!--Two-dimensional code content - - }); + JQuery ('#qrcodeCanvas'). QRCode ({ - Text:"http://www.baidu.com" + }); A </Script> at </Body> - </HTML>
Because the plugin is using jquery, we need to introduce jquery support. There are two ways to generate the QR code, one is to use the Web page table to generate the Web page. Another is to use canvas to generate images directly.