We can use qrcodejs to realize js to generate QR code. qrcodejs is a cross-browser QRCode generator for JavaScript, which can be very simple to implement. QR code generation
1: Download the qrcodejs plug-in
qrcode address: https://github.com/davidshimj...
The downloaded qrcode file is as follows , among which qrcode.js and qrcide.min.js are the js we need, qrcode.min.js is the compressed version of qrcode.js
2: Implement QR code generation
1: The js that needs to be introduced
qrcodejs is designed to be implemented on the premise of jquery, so we first need to introduce jquery and then introduce qrcodejs
<script></script> <!--引入jquery--> <script></script> <!--引入qrcodejs-->
2: Use qrcode to implement QR code Generate
<p></p> <script> new QRCode(document.getElementById("qrcode"), "https://wj0511.com"); </script>
At this time, when we visit the current page, we can see the QR code we generated. After scanning the QR code, visit https://www.wj0511.com
Here we mainly explain some basic parameters of the following new QRCode
The QR code we generated above can jump to the specified url. We can also set some basic parameters of the QR code, as follows
var qrcode = new QRCode(document.getElementById("qrcode"), { text: "https://www.wj0511.com",//扫描二维码后的内容 width: 128,//二维码的宽 height: 128,//二维码的高 colorDark : "#000000",//二维码线条颜色 colorLight : "#ffffff",//二维码背景颜色 correctLevel : QRCode.CorrectLevel.H //二维码等级 });