• qrcode 生成二维码


    qrcode 生成二维码
    Demo:

    qrcodeGithub 地址:

    <!DOCTYPE html>
    <html>
    
    <head>
        <meta charset="UTF-8">
        <title>qrcode生成二维码</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="../plugins/bootstrap-4.1.3-dist/css/bootstrap.min.css">
        <script src="../plugins/echarts/jquery.min.js"></script>
        <script src="../plugins/bootstrap-4.1.3-dist/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="js/jquery.qrcode.min.js"></script>
    </head>
    
    <body>
        <div class="alert alert-primary" role="alert" style="text-align: center;margin:10px;">
            <b>生成的二维码如下:</b>
        </div>
        <div id="qrCodeDiv" style="text-align: center; margin:40px;">
            <img id="qrCodeIco" src="logo.png" style="position: absolute; 64px; height: 64px;" />
        </div>
    </body>
    <script type="text/javascript">
    function utf16to8(str) {
        var out, i, len, c;
        out = "";
        len = str.length;
        for (i = 0; i < len; i++) {
            c = str.charCodeAt(i);
            if ((c >= 0x0001) && (c <= 0x007F)) {
                out += str.charAt(i);
            } else if (c > 0x07FF) {
                out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
                out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
            } else {
                out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
            }
        }
        return out;
    };
    $("#qrCodeDiv").qrcode({
        render: "canvas", //渲染方式有table方式(IE兼容)和canvas方式
         260, //宽度
        height: 260, //高度
        text: utf16to8("https://www.cnblogs.com/hglibin/"), //内容
        typeNumber: -1, //计算模式
        correctLevel: 2, //二维码纠错级别
        background: "#ffffff", //背景颜色
        foreground: "#000000" //二维码颜色
    });
    var margin = ($("#qrCodeDiv").height() - $("#qrCodeIco").height()) / 2; //控制Logo图标的位置
    $("#qrCodeIco").css("margin", margin);
    </script>
    
    </html>
    

    运行结果:

  • 相关阅读:
    Swagger接入
    Elasticsearch5.0.1索引压测结果
    Elasticsearch5.0 BreakChange摘要
    Elasticsearch1.7到2.3升级实践总结
    Java动态代理全面分析
    Spring之AntPathMatcher
    Lock的实现之ReentrantLock详解
    Elasticsearch之client源码简要分析
    elasticserach 索引删除 源码分析
    httpClient4.5.2工具类总结
  • 原文地址:https://www.cnblogs.com/hgnulb/p/9983031.html
Copyright © 2020-2023  润新知