什么是 QRCode.js?
QRCode.js 是一个用于生成二维码的 JavaScript 库。主要是通过获取 DOM 的标签,再通过 HTML5 Canvas 绘制而成,不依赖任何库。

基本用法

1
2
3
4
<div id="qrcode"></div>
<script type="text/javascript">
new QRCode(document.getElementById("qrcode"), "http://www.itnotes.cc/");
</script>

或者使用一些可选参数设置:

1
2
3
4
5
6
7
8
var qrcode = new QRCode("test", {
text: "http://www.itnotes.cc",
width: 128,
height: 128,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});

同样我们可以使用以下方法:

1
2
qrcode.clear(); // 清除代码
qrcode.makeCode("https://www.itnotes.cc"); // 生成另外一个二维码

浏览器支持
支持该库的浏览器有:IE6~10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, 等

Qrcode库下载

云盘下载
提取码: ayab