前端生成二维码
前端生成二维码:
1.引入js
<script type="text/javascript" src="/static/js/qrcode.min.js"></script> <script type="text/javascript" src="/static/js/jquery.js"></script>
2.html写下代码:
<input id="text" type="text" value="http://www.runoob.com" style="width:80%" /><br /> <div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
3.script代码
<script type="text/javascript"> var qrcode = new QRCode(document.getElementById("qrcode"), { width : 100, height : 100 }); function makeCode () { var elText = document.getElementById("text"); if (!elText.value) { alert("Input a text"); elText.focus(); return; } qrcode.makeCode(elText.value); } makeCode(); </script>
大功告成啦!

参考网址:
https://www.runoob.com/w3cnote/javascript-qrcodejs-library.html

浙公网安备 33010602011771号