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 >
        <img  />
    </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方式
    width: 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>

运行结果:
qrcode 生成二维码

相关文章:

  • 2021-12-27
  • 2021-09-01
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-31
  • 2021-10-18
  • 2022-12-23
  • 2021-12-09
  • 2021-11-21
  • 2021-11-21
相关资源
相似解决方案