This article mainly introduces QRCode.js: the use of JS library for generating QR codes based on JQuery. It has certain reference value. Interested students can learn about it and hope it can help everyone.
1. QRCode.js
QRCode.js is a QR code generation javascript library; supports cross-browser HTML5 Canvas and table tag DOM operations; and does not rely on other library or extension.
Homepage: QRCode.js
Github: davidshimjs/qrcodejs
2. Usage
2.1 Basic usage
<p id="qrcode"></p> <script type="text/javascript"> new QRCode(document.getElementById("qrcode"), "https://www.gzpblog.com"); </script>
2.2 Usage of passing parameters
<p id="qrcode"></p> <script type="text/javascript"> var qrcode = new QRCode(document.getElementById("qrcode"), { text: "https://www.gzpblog.com", width: 128, height: 128, colorDark : "#000000", colorLight : "#ffffff", correctLevel : QRCode.CorrectLevel.H }); </script>
2.3 Calling function
qrcode.clear(); // 清除二维码 qrcode.makeCode("https://www.php.cn"); // 创建一个新的二维码
3. Scope of application
I used PHP QR Code to generate QR code before, and found that through this PHP plug-in To generate, there are some minor problems; its internal integration is not very good, it is not very suitable for displaying QR codes directly on the browser, and the style is difficult to control (without saving the QR code file).
The use of QRCode.js can control the style very much, just like a picture, because the picture is directly output to
<p id="qrcode"></p>
, which is very controllable. Just like the previous WeChat payment official sdk, phpsdk was generated using phpqrcode and changed to QRCode.js. After that, a simple effect:
Related recommendations:
HTML5 hybrid development QR code scanning and calling local camera example tutorial
How to implement QR code recognition in PHP - example sharing
The above is the detailed content of QRCode.js JS library instance method for generating QR code based on JQuery. For more information, please follow other related articles on the PHP Chinese website!