jQuery.qrcode
jQuery插件可动态生成QR码。 使用 QR码生成器 (MIT)。
有一个名为 kjua 库,不需要使用jQuery库,可在所有设备上浏览器中使[用]。
引用地址
<script src="https://cdn.jsdelivr.net/gh/lrsjng/jquery-qrcode/dist/jquery-qrcode.min.js"></script>
用法
语法非常简单。只需使用
$(selector).qrcode(options);
如果选择器是一个HTML元素,则将生成的QR码附加到所选元素里。如果所选元素已经是一个canvas元素,则将QR码直接绘制到该元素上。
选项
可用选项及其默认值是:
{
// render method: 'canvas', 'image' or 'div'
render: 'canvas', // 渲染模式 一般选 Image 便于保存
// version range somewhere in 1 .. 40
minVersion: 1, // QR码密集度
maxVersion: 40,
// error correction level: 'L', 'M', 'Q' or 'H'
ecLevel: 'L', // 容错等级
// offset in pixel if drawn onto existing canvas
left: 0, // 绘制起始点的偏移位置
top: 0,
// size in pixel
size: 200, // 二维码的尺寸
// code color or image element
fill: '#000', // 填充色,QR码的前景色
// background color or image element, null for transparent background
background: null, // 背景色
// content
text: 'no text', // QR码内容
// corner radius relative to module width: 0.0 .. 0.5
radius: 0, // 圆角度数
// quiet zone in modules
quiet: 0, // QR与边框距离 1-4
// modes
// 0: normal // 只有QR
// 1: label strip // 带文字,中间留空
// 2: label box // 带文字,字体被包围
// 3: image strip // 图片一行留空
// 4: image box // 图片被包围
mode: 0,
mSize: 0.1, // logo 尺寸位置
mPosX: 0.5,
mPosY: 0.5,
label: 'no label', // logo标志位文本
fontname: 'sans', // 字体
fontcolor: '#000', // 字体颜色
image: null // logo图片
}