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
🌾 效果(扫码有惊喜哦)