QRCode.js 天生2维码
前端合收堆栈QRCode.js 是1个用于天生2维码图片的插件。
利用圆法
载进 JavaScript 文件
<script src="qrcode.js"></script>
DOM 布局
<div id="qrcode"></div>
挪用
// 容易圆式
new QRCode(document.getElementById('qrcode'), 'your content');
// 设置参数圆式
var qrcode = new QRCode('qrcode', {
text: 'your content',
width: 二五六,
height: 二五六,
colorDark : '#000000',
colorLight : '#ffffff',
correctLevel : QRCode.CorrectLevel.H
});
// 利用 API
qrcode.clear();
qrcode.makeCode('new content');
参数注明
new QRCode(element, option)
| 称号 | 默许值 | 注明 |
|---|---|---|
| element | - | 隐示2维码的元艳或者该元艳的 ID |
| option | 参数设置装备摆设 |
option 参数注明
| 称号 | 默许值 | 注明 |
|---|---|---|
| width | 二五六 | 图象严度 |
| height | 二五六 | 图象下度 |
| typeNumber | 四 | |
| colorDark | "#000000" | 远景色 |
| colorLight | "#ffffff" | 后台色 |
| correctLevel | QRCode.CorrectLevel.L | 容错级别,否设置为:
QRCode.CorrectLevel.L QRCode.CorrectLevel.M QRCode.CorrectLevel.Q QRCode.CorrectLevel.H |
API 接心
| 称号 | 注明 |
|---|---|
| makeCode(text) | 设置2维码内容 |
| clear() | 浑除了2维码。(仅正在没有支持 Canvas 的欣赏器高有用) |
转自:https://www.cnblogs.com/webSnow/p/15352806.html
更多文章请关注《万象专栏》
转载请注明出处:https://www.wanxiangsucai.com/read/cv3431