WEB H5 JS QRCode二维码快速自动生成

时间:2024-01-22 08:47:51

万能的GITHUB:

https://github.com/davidshimjs/qrcodejs

HTML:

<div class="col-xs-10 col-xs-offset-1 text-center" id="qrcode"></div>

JavaScript:

<script src="~/js/bundle/jquery/jquery.js"></script>
<script src="~/js/bundle/qrcode/qrcode.js"></script>
<script>
    window.onload = function (){
        makeCode();
    }
    var qrcode = new QRCode("qrcode", {
        text: "我叫二维码",
        width: 80,
        height: 80,
        colorDark: "#000000",
        colorLight: "#ffffff",
        correctLevel: QRCode.CorrectLevel.H
    });
</script>

  这样,当页面完成加载后,就会自动生成一个二维码了,非常简单.

  其中,new QRCode("qrcode" ,这个qrcode与Div的ID对应.