• 使用jquery-qrcode生成二维码


    一、jquery.qrcode.min.js 是把它用jquery方式封装起来的,用它来实现图形渲染,其实就是画图(支持canvas和table两种方式)

    支持的参数主要有:

        render   : "canvas",//设置渲染方式  
        width       : 256,     //设置宽度  
        height      : 256,     //设置高度  
        typeNumber  : -1,      //计算模式  
        correctLevel    : 0,//纠错等级  
        background      : "#ffffff",//背景颜色  
        foreground      : "#000000" //前景颜色  
    

     使用方式:

    jQuery('#qrcode').qrcode({
        render: "table", //table,canvas方式
         200, //宽度 
        height: 200, //高度 
        text: "http://mobile.gzmsg.com" //任意内容 
    });
    

     二、JS生成中文二维码

    function toUtf8(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;
    } 
    

     实例代码如下:下载附件

  • 相关阅读:
    centos7配置vsftpd
    vsftpd上传文件出现553 Could not create file错误解决方法
    mysql表引擎myisam改为innodb
    python字符串
    linux虚拟机设置本地yum源
    python3读取excel数据
    expect远程登录服务器并执行命令
    sed中支持变量的处理方法
    test
    test
  • 原文地址:https://www.cnblogs.com/sntetwt/p/4916959.html
Copyright © 2020-2023  润新知