Using JavaScript to generate QR code tutorial - with qrcodejs Chinese documentation

Using javascript to generate QR code depends on jquery

Libraries to be used


https://github.com/davidshimjs/qrcodejs

DIV

<div id="qrcode"></div>

javascript

 var qrcode = new QRCode("qrcode");
 
  qrcode.makeCode("http://www.fengkaichang.com");
 

So far a simple QR code is generated

image

Next, let's take a closer look at what parameter configurations and methods this library provides us with

configure

new  QRCode(element,option)
name Defaults Types of illustrate
element - string The element that displays the QR code or the ID of the element
option objec parameter configuration
name Defaults Types of illustrate
text - string QR code content to be generated
width 256 number image width
height 256 number image height
colorDark "#000000" string Foreground color
colorLight "#ffffff" string Background color
correctLevel QRCode.CorrectLevel.L fault tolerance level

fault tolerance level

QRCode.CorrectLevel.L
QRCode.CorrectLevel.M
QRCode.CorrectLevel.Q
QRCode.CorrectLevel.H

var qrcode = new  QRCode(element), {
	text: "www,fengkaichang.com",
	width: 150,
	height: 150,
	colorDark : "#000000",
	colorLight : "#ffffff",
	typeNumber:4,
	correctLevel : QRCode.CorrectLevel.H
});

API methods

qrcode.makeCode(text)	//设置二维码内容
qrcode.clear() //清除二维码。

Related Information GitHub Chinese Documentation


For more content, please visit my personal blog www.fengkaichang.com

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325874749&siteId=291194637
Recommended