JS生成二維碼,以下介紹3種方法
🌲 QR碼生成器(在線,反應慢)
🌾 api說明
🌾 使用說明
<h2>QR碼</h2>
<!-- data=后面的鏈接換成需要的鏈接即可 -->
<img style="width: 120px;height: 120px;" src="https://api.qrserver.com/v1/create-qr-code?data=https://mp.weixin.qq.com/s/MvgBo5N2HvE_XvNSHNIw3w">
🌾 效果(掃碼有驚喜哦)
🌲 QRCode.js(可在線可本地)
🌾 github地址
🌾 使用說明
<h2>QRCode.js</h2>
<div id="qrcode"></div>
<script type="text/javascript" src="qrcode.js"></script>
<script type="text/javascript">
// 正常二維碼
new QRCode(document.getElementById("qrcode"), "https://mp.weixin.qq.com/s/MvgBo5N2HvE_XvNSHNIw3w");
// 帶背景色二維碼
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: "https://mp.weixin.qq.com/s/MvgBo5N2HvE_XvNSHNIw3w",
width: 128,
height: 128,
colorDark: "#f60",
colorLight: "#ccc",
correctLevel: 0 // 二維碼結構復雜性 0~3
});
</script>
🌾 效果(掃碼有驚喜哦)
🌲 arale-qrcode(可在線可本地可安裝)
🌾 github地址
🌾 使用說明
<h2>arale-qrcode</h2>
<script src="./arale-qrcode.js"></script>
<div id="share_tools"></div>
<script type="text/javascript">
var codeFigure = new AraleQRCode({
"render": "svg", // 生成的類型 'svg' or 'table'
"text": 'https://mp.weixin.qq.com/s/MvgBo5N2HvE_XvNSHNIw3w', // 需要生成二維碼的鏈接
"size": 160 // 生成二維碼大小
});
var share_tools = document.querySelector('#share_tools');
share_tools.appendChild(codeFigure);
</script>
// 如果安裝
npm i arale-qrcode
🌾 效果(掃碼有驚喜哦)