GitHub地址: https://github.com/jeromeetienne/jquery-qrcode

    <div class="QR"></div>            

    jQuery('.QR').qrcode({//QR填充二维码的div //render:'table', render:'canvas', width : 200, height : 200, text : utf16to8("这里填写二维码显示内容, 可以是文字, 也可以是url"),//中文文字需要转换 //text : url,// url不用转换,直接使用 typeNumber:-1,//计算模式 correctLevel:2,//二维码纠错级别 /* background:"#ffffff",//背景颜色 foreground:"#000000" //二维码颜色 */ }); //二维码中的中文转换 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; }

 

转载于:https://www.cnblogs.com/gczmn/p/9381156.html

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐