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;}
更多专业前端知识,请上 【猿2048】www.mk2048.com