{"id":4104,"date":"2015-08-07T17:14:29","date_gmt":"2015-08-07T09:14:29","guid":{"rendered":"https:\/\/sdeno.com\/?p=4104"},"modified":"2024-06-13T22:38:54","modified_gmt":"2024-06-13T14:38:54","slug":"%e6%9c%ac%e5%9c%b0%e7%94%9f%e6%88%90%e4%ba%8c%e7%bb%b4%e7%a0%81","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=4104","title":{"rendered":"jquery.qrcode.min.js \u672c\u5730\u751f\u6210\u4e8c\u7ef4\u7801"},"content":{"rendered":"<p>js \u751f\u6210 \u4e8c\u7ef4\u7801<\/p>\n<p><a href=\"https:\/\/sdeno.com\/zp\/erweima\/\" target=\"_blank\" rel=\"noopener\">\u5728\u7ebf\u751f\u6210\u4e8c\u7ef4\u7801<\/a><\/p>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2015\/08\/erweima2.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:197px\"><div style=\"padding-top:76.142131979695%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"197\" height=\"150\" class=\"alignnone size-full wp-image-4105 lazyload\" title=\"erweima2\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2015\/08\/erweima2.jpg\" alt=\"erweima2\"><\/figure><\/a>\n<p>\u672c\u5730\u751f\u6210\u4e8c\u7ef4\u7801<\/p>\n<p>\u4e0b\u8f7d\uff1a<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2021\/02\/q.js\" target=\"_blank\" rel=\"noopener\">qrcode.js<\/a><\/p>\n<p>&nbsp;<\/p>\n<pre>&lt;div id=\"qrcode\" style=\"width:100px; height:100px; margin-top:15px;\"&gt;&lt;\/div&gt;\r\nvar aa= JSON.stringify( {\r\n    \"type\":\"2\",\r\n    \"data\":{\r\n        \"accountName\":\"wyx334455\",\r\n        \"amount\":\"100\",\r\n        \"coinSymbol\":\"LCNY\",\r\n        \"contract\":\"eosio.stable\",\r\n        \"memo\":\"\u6d4b\u8bd5\",\r\n        \"canModify\":\"0\"\r\n    }\r\n} )\r\n\r\n\r\nnew QRCode(document.getElementById(\"qrcode\"), {\r\n    width : 100,\r\n    height : 100,\r\n   \/\/ correctLevel : QRCode.CorrectLevel.H\r\n}).makeCode( aa );<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var aa= JSON.stringify( {\r\n        \"type\":\"2\",\r\n        \"data\":{\r\n            \"accountName\":\"wyx334455\",\r\n            \"amount\":\"100\",\r\n            \"coinSymbol\":\"LCNY\",\r\n            \"contract\":\"eosio.stable\",\r\n            \"memo\":\"\u6d4b\u8bd5\",\r\n            \"canModify\":\"0\"\r\n        }\r\n    } )\r\n\r\n\r\n   var ss = new QRCode(document.getElementById(\"qrcode\"),'55555', {\r\n        width : 100,\r\n        height : 100,\r\n        \/\/ correctLevel : QRCode.CorrectLevel.H\r\n    })\r\n   \r\n\r\n\r\n\r\n    \/\/ \u83b7\u53d6\u7236\u5143\u7d20\r\n    const parentElement = ss._el;\r\n    console.log(parentElement)\r\n    \/\/ \u83b7\u53d6\u5b50\u5143\u7d20\u4e2d\u7684\u7b2c\u4e00\u4e2aimg\u5143\u7d20\r\n    const imgElement = parentElement.querySelector('img');\r\n    console.log(imgElement)\r\n    imgElement.onload=function(){\r\n        const imgSrc = imgElement.src;\r\n\r\n        console.log(imgSrc);  \/\/\u83b7\u53d6\u5230base64\r\n    }<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p style=\"color: #424242;\">1\u3001\u9996\u5148\u5728\u9875\u9762\u4e2d\u52a0\u5165jquery\u5e93\u6587\u4ef6\u548cqrcode\u63d2\u4ef6\u3002<\/p>\n<pre style=\"color: #424242;\"><code class=\"html\"><span class=\"html__tag_start\" style=\"font-weight: bold; color: navy;\">&lt;script<\/span>\u00a0<span class=\"html__attr_name\" style=\"color: green;\">type<\/span>=<span class=\"html__attr_value\" style=\"color: maroon;\">\"text\/javascript\"<\/span>\u00a0<span class=\"html__attr_name\" style=\"color: green;\">src<\/span>=<span class=\"html__attr_value\" style=\"color: maroon;\">\"jquery.js\"<\/span><span class=\"html__tag_start\" style=\"font-weight: bold; color: navy;\">&gt;<\/span><span class=\"html__tag_end\" style=\"color: navy;\">&lt;\/script&gt;<\/span>\u00a0\r\n<span class=\"html__tag_start\" style=\"font-weight: bold; color: navy;\">&lt;script<\/span>\u00a0<span class=\"html__attr_name\" style=\"color: green;\">type<\/span>=<span class=\"html__attr_value\" style=\"color: maroon;\">\"text\/javascript\"<\/span>\u00a0<span class=\"html__attr_name\" style=\"color: green;\">src<\/span>=<span class=\"html__attr_value\" style=\"color: maroon;\">\"jquery.qrcode.min.js\"<\/span><span class=\"html__tag_start\" style=\"font-weight: bold; color: navy;\">&gt;<\/span><span class=\"html__tag_end\" style=\"color: navy;\">&lt;\/script&gt;<\/span>\u00a0<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p style=\"color: #424242;\">2\u3001\u5728\u9875\u9762\u4e2d\u9700\u8981\u663e\u793a\u4e8c\u7ef4\u7801\u7684\u5730\u65b9\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre style=\"color: #424242;\"><code class=\"html\"><span class=\"html__tag_start\" style=\"font-weight: bold; color: navy;\">&lt;div<\/span>\u00a0<span class=\"html__attr_name\" style=\"color: green;\">id<\/span>=<span class=\"html__attr_value\" style=\"color: maroon;\">\"code\"<\/span><span class=\"html__tag_start\" style=\"font-weight: bold; color: navy;\">&gt;<\/span><span class=\"html__tag_end\" style=\"color: navy;\">&lt;\/div&gt;<\/span>\u00a0<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p style=\"color: #424242;\">3\u3001\u8c03\u7528qrcode\u63d2\u4ef6\u3002<\/p>\n<p style=\"color: #424242;\">qrcode\u652f\u6301canvas\u548ctable\u4e24\u79cd\u65b9\u5f0f\u8fdb\u884c\u56fe\u7247\u6e32\u67d3\uff0c\u9ed8\u8ba4\u4f7f\u7528canvas\u65b9\u5f0f\uff0c\u6548\u7387\u6700\u9ad8\uff0c\u5f53\u7136\u8981\u6d4f\u89c8\u5668\u652f\u6301html5\u3002\u76f4\u63a5\u8c03\u7528\u5982\u4e0b\uff1a<\/p>\n<pre style=\"color: #424242;\"><code class=\"js\">$(<span class=\"js__string\" style=\"color: teal;\">'#code'<\/span>).qrcode(<span class=\"js__string\" style=\"color: teal;\">\"http:\/\/www.helloweba.com\"<\/span>);\u00a0<span class=\"js__sl_comment\" style=\"color: green;\">\/\/\u4efb\u610f\u5b57\u7b26\u4e32<\/span>\u00a0\r\n<\/code><\/pre>\n<p style=\"color: #424242;\">\u60a8\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8c03\u7528\uff1a<\/p>\n<pre style=\"color: #424242;\"><code class=\"js\">$(<span class=\"js__string\" style=\"color: teal;\">\"#code\"<\/span>).qrcode(<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">{<\/span>\u00a0\r\n\u00a0\u00a0\u00a0\u00a0render:\u00a0<span class=\"js__string\" style=\"color: teal;\">\"table\"<\/span>,\u00a0<span class=\"js__sl_comment\" style=\"color: green;\">\/\/table\u65b9\u5f0f<\/span>\u00a0\r\n\u00a0\u00a0\u00a0\u00a0width:\u00a0<span class=\"js__num\" style=\"color: red;\">200<\/span>,\u00a0<span class=\"js__sl_comment\" style=\"color: green;\">\/\/\u5bbd\u5ea6<\/span>\u00a0\r\n\u00a0\u00a0\u00a0\u00a0height:<span class=\"js__num\" style=\"color: red;\">200<\/span>,\u00a0<span class=\"js__sl_comment\" style=\"color: green;\">\/\/\u9ad8\u5ea6<\/span>\u00a0\r\n\u00a0\u00a0\u00a0\u00a0text:\u00a0<span class=\"js__string\" style=\"color: teal;\">\"www.helloweba.com\"<\/span>\u00a0<span class=\"js__sl_comment\" style=\"color: green;\">\/\/\u4efb\u610f\u5185\u5bb9<\/span>\u00a0\r\n<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">}<\/span>);\u00a0\r\n<\/code><\/pre>\n<p style=\"color: #424242;\">\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u9875\u9762\u4e2d\u76f4\u63a5\u751f\u6210\u4e00\u4e2a\u4e8c\u7ef4\u7801\uff0c\u4f60\u53ef\u4ee5\u7528\u624b\u673a\u201c\u626b\u4e00\u626b\u201d\u529f\u80fd\u8bfb\u53d6\u4e8c\u7ef4\u7801\u4fe1\u606f\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4 style=\"color: #424242;\">\u8bc6\u522b\u4e2d\u6587<\/h4>\n<p style=\"color: #424242;\">\u6211\u4eec\u8bd5\u9a8c\u7684\u65f6\u5019\u53d1\u73b0\u4e0d\u80fd\u8bc6\u522b\u4e2d\u6587\u5185\u5bb9\u7684\u4e8c\u7ef4\u7801\uff0c\u901a\u8fc7\u67e5\u627e\u591a\u65b9\u8d44\u6599\u4e86\u89e3\u5230\uff0cjquery-qrcode\u662f\u91c7\u7528charCodeAt()\u65b9\u5f0f\u8fdb\u884c\u7f16\u7801\u8f6c\u6362\u7684\u3002\u800c\u8fd9\u4e2a\u65b9\u6cd5\u9ed8\u8ba4\u4f1a\u83b7\u53d6\u5b83\u7684Unicode\u7f16\u7801\uff0c\u5982\u679c\u6709\u4e2d\u6587\u5185\u5bb9\uff0c\u5728\u751f\u6210\u4e8c\u7ef4\u7801\u524d\u5c31\u8981\u628a\u5b57\u7b26\u4e32\u8f6c\u6362\u6210UTF-8\uff0c\u7136\u540e\u518d\u751f\u6210\u4e8c\u7ef4\u7801\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51fd\u6570\u6765\u8f6c\u6362\u4e2d\u6587\u5b57\u7b26\u4e32\uff1a<\/p>\n<pre style=\"color: #424242;\"><code class=\"js\"><span class=\"js__operator\" style=\"font-weight: bold; color: royalblue;\">function<\/span>\u00a0toUtf8(str)\u00a0<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">{<\/span>\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0<span class=\"js__statement\" style=\"font-weight: bold; color: navy;\">var<\/span>\u00a0out,\u00a0i,\u00a0len,\u00a0c;\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0out\u00a0=\u00a0<span class=\"js__string\" style=\"color: teal;\">\"\"<\/span>;\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0len\u00a0=\u00a0str.length;\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0<span class=\"js__statement\" style=\"font-weight: bold; color: navy;\">for<\/span>(i\u00a0=\u00a0<span class=\"js__num\" style=\"color: red;\">0<\/span>;\u00a0i\u00a0&lt;\u00a0len;\u00a0i++)\u00a0<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">{<\/span>\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0c\u00a0=\u00a0str.charCodeAt(i);\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"js__statement\" style=\"font-weight: bold; color: navy;\">if<\/span>\u00a0((c\u00a0&gt;=\u00a00x0001)\u00a0&amp;&amp;\u00a0(c\u00a0&lt;=\u00a00x007F))\u00a0<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">{<\/span>\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0out\u00a0+=\u00a0str.charAt(i);\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">}<\/span>\u00a0<span class=\"js__statement\" style=\"font-weight: bold; color: navy;\">else<\/span>\u00a0<span class=\"js__statement\" style=\"font-weight: bold; color: navy;\">if<\/span>\u00a0(c\u00a0&gt;\u00a00x07FF)\u00a0<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">{<\/span>\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0out\u00a0+=\u00a0<span class=\"js__object\" style=\"color: deeppink;\">String<\/span>.fromCharCode(0xE0\u00a0|\u00a0((c\u00a0&gt;&gt;\u00a0<span class=\"js__num\" style=\"color: red;\">12<\/span>)\u00a0&amp;\u00a00x0F));\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0out\u00a0+=\u00a0<span class=\"js__object\" style=\"color: deeppink;\">String<\/span>.fromCharCode(0x80\u00a0|\u00a0((c\u00a0&gt;&gt;\u00a0\u00a0<span class=\"js__num\" style=\"color: red;\">6<\/span>)\u00a0&amp;\u00a00x3F));\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0out\u00a0+=\u00a0<span class=\"js__object\" style=\"color: deeppink;\">String<\/span>.fromCharCode(0x80\u00a0|\u00a0((c\u00a0&gt;&gt;\u00a0\u00a0<span class=\"js__num\" style=\"color: red;\">0<\/span>)\u00a0&amp;\u00a00x3F));\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">}<\/span>\u00a0<span class=\"js__statement\" style=\"font-weight: bold; color: navy;\">else<\/span>\u00a0<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">{<\/span>\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0out\u00a0+=\u00a0<span class=\"js__object\" style=\"color: deeppink;\">String<\/span>.fromCharCode(0xC0\u00a0|\u00a0((c\u00a0&gt;&gt;\u00a0\u00a0<span class=\"js__num\" style=\"color: red;\">6<\/span>)\u00a0&amp;\u00a00x1F));\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0out\u00a0+=\u00a0<span class=\"js__object\" style=\"color: deeppink;\">String<\/span>.fromCharCode(0x80\u00a0|\u00a0((c\u00a0&gt;&gt;\u00a0\u00a0<span class=\"js__num\" style=\"color: red;\">0<\/span>)\u00a0&amp;\u00a00x3F));\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">}<\/span>\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">}<\/span>\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0<span class=\"js__statement\" style=\"font-weight: bold; color: navy;\">return<\/span>\u00a0out;\u00a0\u00a0\u00a0\u00a0\r\n<span class=\"js__brace\" style=\"font-weight: bold; color: red;\">}<\/span>\u00a0<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p style=\"color: #424242;\">\u4ee5\u4e0b\u793a\u4f8b\uff1a<\/p>\n<pre style=\"color: #424242;\"><code class=\"js\"><span class=\"js__statement\" style=\"font-weight: bold; color: navy;\">var<\/span>\u00a0str\u00a0=\u00a0toUtf8(<span class=\"js__string\" style=\"color: teal;\">\"\u9493\u9c7c\u5c9b\u662f\u4e2d\u56fd\u7684\uff01\"<\/span>);\u00a0\r\n$(<span class=\"js__string\" style=\"color: teal;\">'#code'<\/span>).qrcode(str);\u00a0<\/code><\/pre>\n<p><a href=\"http:\/\/pan.baidu.com\/s\/1eRhuBcA\" target=\"_blank\" rel=\"noopener\">http:\/\/pan.baidu.com\/s\/1eRhuBcA<\/a><\/p>\n<p><a href=\"http:\/\/www.helloweba.com\/view-blog-226.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.helloweba.com\/view-blog-226.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>js \u751f\u6210 \u4e8c\u7ef4\u7801 \u5728\u7ebf\u751f\u6210\u4e8c\u7ef4\u7801 \u672c\u5730\u751f\u6210\u4e8c\u7ef4\u7801 \u4e0b\u8f7d\uff1aqrcode.js &nbsp; &lt;div i [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-4104","post","type-post","status-publish","format-standard","hentry","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4104"}],"version-history":[{"count":1,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4104\/revisions"}],"predecessor-version":[{"id":9763,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4104\/revisions\/9763"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}