Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize QR Code with javascript

Shulou Source: shulou.com Published: 2022-05-31 11:56:36 10月05日 Update

Most people do not understand the knowledge points of this article "javascript how to achieve QR code", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to achieve QR code in javascript" article.

Javascript to achieve QR code methods: 1, download qrcodejs plug-in; 2, use qrcode to achieve QR code generation, such as "new QRCode (document.getElementById (" qrcode ")".

This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.

How does javascript realize the QR code?

Realization of QR Code Generation by js

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 generate QR code.

One: download the qrcodejs plug-in

The downloaded qrcode file is as follows, in which qrcode.js and qrcide.min.js are the js,qrcode.min.js we need and the qrcode.js compressed version

Second: realize the generation of QR code

1: js to be introduced

Qrcodejs is designed to be implemented under the premise of jquery, so we need to introduce jquery before introducing qrcodejs.

2: using qrcode to generate QR code

New QRCode (document.getElementById ("qrcode"), "https://wj0511.com");"

At this time, we visit the current page and we can see the QR code we generated. Scan the QR code and visit https://www.wj0511.com.

Here are some of the basic parameters of new QRCode

The QR code generated above can be redirected to the specified url, and we can also set some basic parameters of the QR code, as follows

Var qrcode = new QRCode (document.getElementById ("qrcode"), {text: "content of https://www.wj0511.com",// scanned QR code width: 128 QR code width height: 128 QR code high colorDark:" # 000000 ", / / QR code line color colorLight:" # ffffff ", / / QR code background color correctLevel: QRCode.CorrectLevel.H / / QR code grade}) The above is about the content of this article on "how to realize the QR code in javascript". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: 2D QR code generation content parameters that is plug-ins articles knowledge articles colors codes values premises most plug-in downloads files methods more steps Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MySQL MariaDB Shulou Information vpn