1.引入JS

源项目地址

1
<script src="https://curi-t.github.io/online/js/qrcode/qrcode.js">

压缩后

1
<script src="https://curi-t.github.io/online/js/qrcode/qrcode.min.js">

2.使用方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="qrcode.js"></script>
</head>

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

<script type="text/javascript">
new QRCode(document.getElementById("qrcode"), "https://github.com/davidshimjs/qrcodejs");
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: "生成二维码的方法不止一种",
width: 128,
height: 128,
colorDark : "#f60",
colorLight : "#ccc",
correctLevel : 0 // 二维码结构复杂性 0~3
});
</script>
</body>
</html>