Home > Web Front-end > JS Tutorial > body text

QRCode.js JS library instance method for generating QR code based on JQuery

小云云
Release: 2018-01-06 10:50:51
Original
2467 people have browsed it

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>
Copy after login

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>
Copy after login

2.3 Calling function

qrcode.clear(); // 清除二维码
qrcode.makeCode("https://www.php.cn"); // 创建一个新的二维码
Copy after login

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>
Copy after login

, 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 implements the function of sharing QR codes on major WeChat QQ and other communication platforms

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template