QRCode.js 生成二維碼
阿新 • • 發佈:2018-09-28
.get qrcode.js 背景色 簡單 tel rda 前景 col 默認值 載入 JavaScript 文件
<script src="qrcode.js"></script>
DOM 結構
<div id="qrcode"></div>
調用
1、 簡單方式new QRCode(document.getElementById(‘qrcode‘), ‘your content‘);
2、設置參數方式
var qrcode = new QRCode(‘qrcode‘, { text: ‘your content‘, width: 256, height: 256, colorDark : ‘#000000‘, colorLight : ‘#ffffff‘, correctLevel : QRCode.CorrectLevel.H });
new QRCode(element, option)
element 顯示二維碼的元素或該元素的 ID
option 參數說明
名稱 | 默認值 | 說明 |
---|---|---|
text | string | 二維碼內容 |
width | 256 | 圖像寬度 |
height | 256 | 圖像高度 |
type | Number | 4 |
colorDark | "#000000" | 前景色 |
colorLight | "#ffffff" | 背景色 |
correctLevel | QRCode.CorrectLevel.L | 容錯級別,可設置為:QRCode.CorrectLevel.L,QRCode.CorrectLevel.M,QRCode.CorrectLevel.Q,QRCode.CorrectLevel.H |
API 接口
qrcode.clear();
qrcode.makeCode(‘new content‘);
makeCode(text) 設置二維碼內容
clear() 清除二維碼。(僅在不支持 Canvas 的瀏覽器下有效)
QRCode.js 生成二維碼