{"id":10678,"date":"2023-01-07T18:09:17","date_gmt":"2023-01-07T10:09:17","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10678"},"modified":"2023-01-07T18:09:17","modified_gmt":"2023-01-07T10:09:17","slug":"js-parse-barcode-qrcode-barcodedetector","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2023\/01\/js-parse-barcode-qrcode-barcodedetector\/","title":{"rendered":"\u524d\u7aef\u539f\u751fAPI\u5b9e\u73b0\u6761\u5f62\u7801\u4e8c\u7ef4\u7801\u7684JS\u89e3\u6790\u8bc6\u522b"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10678\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10678<\/a> \u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202301-parse-qrcode.png';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/qrcode-cover.png\" width=\"480\" height=\"297\" alt=\"qrcode\u5c01\u9762\u56fe\" class=\"alignright clip thumb size-medium\" \/><\/p>\n<p>\u4eca\u5929\u624d\u77e5\u9053\uff0c\u6d4f\u89c8\u5668\u7eafJS\u4e0d\u4ec5\u53ef\u4ee5\u751f\u6210\u6761\u5f62\u7801\u548c\u4e8c\u7ef4\u7801\uff0c\u8fd8\u539f\u751f\u652f\u6301\u5bf9\u6761\u5f62\u7801\u548c\u4e8c\u7ef4\u7801\u7684\u89e3\u6790\u3002<\/p>\n<h3>\u4e00\u3001BarcodeDetector API<\/h3>\n<p>\u6d4f\u89c8\u5668\u89e3\u6790\u4e8c\u7ef4\u7801\u3001\u6761\u5f62\u7801\u4f7f\u7528\u7684\u662fBarcode Detection API\u3002<\/p>\n<p>\u5176\u4f7f\u7528\u5957\u8def\u90fd\u662f\u56f4\u7ed5\u4e0b\u9762\u8fd9\u4e09\u4e2a\u5c55\u5f00\u3002<\/p>\n<h4>1. \u58f0\u660e\u68c0\u6d4b\u5668<\/h4>\n<p>\u4f7f\u7528 <code>BarcodeDetector<\/code> \u6784\u9020\u4e00\u4e2a\u68c0\u6d4b\u5668\u3002<\/p>\n<pre>if ('BarcodeDetector' in window) {\r\n  \/\/ \u521b\u5efa\u68c0\u6d4b\u5668\r\n  const barcodeDetector = new BarcodeDetector({\r\n    \/\/ formats \u662f\u68c0\u6d4b\u7684\u6761\u7801\u683c\u5f0f\u7c7b\u578b\r\n    formats: ['qr_code']\r\n  });\r\n}<\/pre>\n<p>\u5176\u4e2d\uff0c\u4f7f\u7528 formats \u53c2\u6570\u58f0\u660e\u68c0\u6d4b\u7684\u6761\u7801\u7c7b\u578b\u3002<\/p>\n<p>\u652f\u6301\u5404\u79cd\u7c7b\u578b\u7684\u6761\u5f62\u7801\u548c\u4e8c\u7ef4\u7801\uff0c\u5177\u4f53\u89c1\u4e0b\u8868\uff1a<\/p>\n<table border=\"0\" width=\"100%\" class=\"params_table\" cellspacing=\"1\">\n<thead>\n<tr>\n<th>\u683c\u5f0f<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u56fe\u793a<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>aztec<\/td>\n<td>\u9075\u5faaiso24778\u89c4\u5219\u7684\u4e8c\u7ef4\u65b9\u578b\u77e9\u9635\uff0c\u5f62\u4f3cAztec\u91d1\u5b57\u5854\uff0c\u4e0d\u9700\u8981\u5916\u9762\u6709\u7a7a\u767d\u533a\u57df\u3002\n      <\/td>\n<td>\n        <img decoding=\"async\" alt=\"Aztec barcode\uff0c\u7531\u5c0f\u7684\u65b9\u578b\u9ed1\u767d\u5757\u7ec4\u6210\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/aztec.gif\" width=\"76\" height=\"76\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>code_128<\/td>\n<td>\u7ebf\u6027\uff08\u4e00\u7ef4\uff09\u3001\u53cc\u5411\u53ef\u89e3\u7801\u3001\u81ea\u68c0\uff0c\u6761\u5f62\u7801\u9075\u5faaiso15417\u89c4\u8303\uff0c\u80fd\u591f\u7f16\u7801\u6240\u6709128\u4e2aASCII\u5b57\u7b26\uff08\u6545\u56e0\u6b64\u547d\u540d\uff09\u3002\n      <\/td>\n<td>\n        <img decoding=\"async\" alt=\"code-128\u7f16\u7801\u793a\u610f\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/code-128.gif\" width=\"300\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>code_39<\/td>\n<td>\n        \u9075\u5faaiso16388\u89c4\u8303\u7684\u7ebf\u6027\uff08\u4e00\u7ef4\uff09\u81ea\u68c0\u6761\u5f62\u7801\u3002\u5b83\u662f\u79bb\u6563\u7684\u53ef\u53d8\u957f\u5ea6\u6761\u5f62\u7801\u7c7b\u578b\u3002\n      <\/td>\n<td>\n        <img decoding=\"async\" alt=\"code-39\u7f16\u7801\u793a\u610f\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/code-39.png\" width=\"300\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>code_93<\/td>\n<td>\u4e00\u79cd\u91c7\u7528bc5\u89c4\u8303\uff0c\u7ebf\u6027\u7684\u3001\u8fde\u7eed\u7b26\u53f7\uff0c\u957f\u5ea6\u53ef\u53d8\u7684\u7f16\u7801\u3002\u548ccode_128\u89c6\u89c9\u4e0a\u76f8\u4f3c\uff0c\u63d0\u4f9b\u7684\u4fe1\u606f\u5bc6\u5ea6\u6bd4\u7684code_39\u66f4\u5927\u3002code_93\u4e3b\u8981\u7528\u5728\u52a0\u62ff\u5927\u90ae\u653f\uff0c\u7528\u6765\u7f16\u7801\u5feb\u9012\u4fe1\u606f\u3002<\/td>\n<td>\n        <img decoding=\"async\" alt=\"code 93\u683c\u5f0f\u7f16\u7801\u793a\u610f\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/code-93.png\" width=\"300\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>codabar<\/td>\n<td>\u4e00\u79cd\u7528\u6765\u8868\u793a\u5b57\u7b260-9, A-D \u4ee5\u53ca\u7b26\u53f7 &#8211; . $ \/ +\u7684\u7ebf\u6027\u6761\u5f62\u7801<\/td>\n<td>\n        <img decoding=\"async\" alt=\"codabar\u683c\u5f0f\u6761\u5f62\u7801\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/codabar.png\" width=\"300\"  loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>data_matrix<\/td>\n<td>\u9075\u5faaiso16022\u89c4\u8303\u7684\u4e0d\u533a\u5206\u53d1\u73b0\u7684\u4e8c\u7ef4\u6761\u7801\uff0c\u4f7f\u7528\u9ed1\u767d\u6a21\u5757\u7ec4\u6210\u3002\n      <\/td>\n<td>\n        <img decoding=\"async\" alt=\"data matrix barcode\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/data-matrix.png\" width=\"300\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>ean_13<\/td>\n<td>\u57fa\u4e8eUPC-A\u6807\u51c6\u5e76\u5728iso15420\u4e2d\u5b9a\u4e49\u7684\u7ebf\u6027\u6761\u5f62\u7801\u3002<\/td>\n<td>\n        <img decoding=\"async\" alt=\"EAN-13\u7f16\u7801\u56fe\u793a\u610f\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/ean-13.png\" width=\"300\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>ean_8<\/td>\n<td>iso15420\u4e2d\u5b9a\u4e49\u7684\u7ebf\u6027\u6761\u5f62\u7801\uff0c\u6e90\u81eaEAN-13\u3002<\/td>\n<td>\n        <img decoding=\"async\" alt=\"EAN-8\u683c\u5f0f\u7684\u7f16\u7801\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/ean-8.png\" width=\"300\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>itf<\/td>\n<td>\n        \u4e00\u79cd\u8fde\u7eed\u3001\u81ea\u68c0\u3001\u53cc\u5411\u53ef\u89e3\u7801\u7684\u6761\u5f62\u7801\u3002\u5b83\u5c06\u59cb\u7ec8\u7f16\u780114\u4f4d\u6570\u5b57\u3002\n      <\/td>\n<td>\n        <img decoding=\"async\" alt=\"ITF Barcode\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/ift.png\" width=\"300\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>pdf417<\/td>\n<td>\n        \u5177\u6709\u591a\u884c\u548c\u591a\u5217\u7684\u8fde\u7eed\u4e8c\u7ef4\u6761\u5f62\u7801\u7b26\u53f7\u683c\u5f0f\u3002\u5b83\u662f\u53cc\u5411\u53ef\u89e3\u7801\u7684\uff0c\u4f7f\u7528iso15438\u6807\u51c6\u3002\n      <\/td>\n<td>\n        <img decoding=\"async\" alt=\"pdf417\u7f16\u7801\u683c\u5f0f\u793a\u610f\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/pdf417.png\" width=\"300\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>qr_code<\/td>\n<td>\n        \u4f7f\u7528iso18004\u6807\u51c6\u7684\u4e8c\u7ef4\u6761\u5f62\u7801\u3002\u7f16\u7801\u7684\u4fe1\u606f\u53ef\u4ee5\u662f\u6587\u672c\u3001URL\u6216\u5176\u4ed6\u6570\u636e\u3002\n      <\/td>\n<td>\n        <img decoding=\"async\" alt=\"QR code\u6848\u4f8b\u793a\u610f\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/qr-code.png\" width=\"150\" height=\"150\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>upc_a<\/td>\n<td>\n        \u6700\u5e38\u89c1\u7684\u7ebf\u6027\u6761\u7801\u7c7b\u578b\u4e4b\u4e00\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u7f8e\u56fd\u7684\u96f6\u552e\u4e1a\u3002\u5728iso15420\u4e2d\u5b9a\u4e49\uff0c\u5b83\u901a\u8fc7\u6761\u5f62\u548c\u7a7a\u683c\u8868\u793a\u6570\u5b57\uff0c\u6bcf\u4e2a\u6570\u5b57\u90fd\u4e0e2\u4e2a\u6761\u5f62\u548c2\u4e2a\u7a7a\u683c\u7684\u552f\u4e00\u6a21\u5f0f\u76f8\u5173\u8054\uff0c\u8fd9\u4e24\u4e2a\u6761\u5f62\u548c\u7a7a\u683c\u7684\u5bbd\u5ea6\u90fd\u662f\u53ef\u53d8\u7684\u3002UPC-A\u53ef\u4ee5\u7f16\u7801\u552f\u4e00\u5206\u914d\u7ed9\u6bcf\u4e2a\u4ea4\u6613\u9879\u76ee\u768412\u4f4d\u6570\u5b57\uff0c\u4ece\u6280\u672f\u4e0a\u8bb2\uff0c\u5b83\u662fEAN-13\u7684\u5b50\u96c6\uff08UPC-A\u4ee3\u7801\u4ee5EAN-13\u8868\u793a\uff0c\u7b2c\u4e00\u4e2a\u5b57\u7b26\u8bbe\u7f6e\u4e3a0\uff09\u3002\n      <\/td>\n<td>\n        <img decoding=\"async\" alt=\"upc-a barcode\u56fe\u793a\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/upc-a.png\" width=\"300\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>upc_e<\/td>\n<td>\n        iso15420\u89c4\u8303\u4e2d\u5b9a\u4e49\u7684UPC-A\u7684\u53d8\u4f53\uff0c\u538b\u7f29\u4e86\u4e0d\u5fc5\u8981\u7684\u96f6\uff0c\u4ee5\u83b7\u5f97\u66f4\u7d27\u51d1\u7684\u6761\u5f62\u7801\u3002\n      <\/td>\n<td>\n        <img decoding=\"async\" alt=\"upc-e\u7f16\u7801\u56fe\u5f62\u793a\u610f\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/upc-e.png\" width=\"300\" loading=\"lazy\">\n      <\/td>\n<\/tr>\n<tr>\n<td>unknown<\/td>\n<td>\n        \u8868\u793a\u5e73\u53f0\u4e0d\u8bc6\u522b\u6b64\u503c\u6216\u88ab\u68c0\u6d4b\u6216\u652f\u6301\u7684\u6307\u5b9a\u7684\u6761\u5f62\u7801\u683c\u5f0f\u3002\n      <\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2. \u652f\u6301\u89e3\u6790\u7684\u6761\u7801\u7c7b\u578b<\/h4>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u53ef\u4ee5\u8bc6\u522b\u652f\u6301\u68c0\u6d4b\u7684\u6761\u7801\u7c7b\u578b\uff1a<\/p>\n<pre>\/\/ \u68c0\u6d4b\u652f\u6301\u7684\u7c7b\u578b\r\nBarcodeDetector.getSupportedFormats().then((supportedFormats) => {\r\n  supportedFormats.forEach((format) => console.log(format));\r\n});<\/pre>\n<p>\u4f8b\u5982\uff0c\u5728\u6211\u7684Mac Chrome\u6d4f\u89c8\u5668\u4e0b\u8fd0\u884c\u7684\u7ed3\u679c\u662f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/20230107-112229min.png\" width=\"468\" height=\"353\" alt=\"\u652f\u6301\u7684\u89e3\u6790\u7c7b\u578b\" class=\"alignnone size-medium\" style=\"border:1px solid #ddd\" \/><\/p>\n<p>\u5171\u652f\u6301\u5341\u4e00\u79cd\u6761\u7801\u7684\u89e3\u6790\uff0c\u5176\u4e2d\u5c31\u5305\u62ec\u5728Web\u9886\u57df\u975e\u5e38\u5e38\u7528\u7684\u4e8c\u7ef4\u7801\u89e3\u6790 &#8211; qr_code\u3002<\/p>\n<h4>3. \u6761\u7801\u7684\u89e3\u6790<\/h4>\n<p>\u5982\u679c\u60f3\u8981\u89e3\u6790\u67d0\u6761\u7801\u56fe\u7247\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3c\u4e0b\u9762\u7684JavaScript\u4ee3\u7801\uff1a<\/p>\n<pre>barcodeDetector.detect(eleImg).then((barcodes) =&gt; {\r\n    barcodes.forEach((barcode) =&gt; {\r\n        console.log('\u89e3\u6790\u7ed3\u679c\u662f\uff1a' + barcode.rawValue);\r\n    });\r\n}).catch((err) =&gt; {\r\n    console.error(`\u89e3\u6790\u51fa\u9519\uff1a${err}`);\r\n});<\/pre>\n<p>\u5176\u4e2d\uff0c<code>eleImg<\/code> \u4e0d\u4ec5\u53ef\u4ee5\u662f <code>&lt;img&gt;<\/code> \u5143\u7d20\uff0cSVGImageElement\u3001HTMLVideoElement\u3001HTMLCanvasElement\u3001ImageBitmap\u3001OffscreenCanvas\u3001VideoFrame\u3001Blob\u56fe\u5f62\u6216ImageData\u6570\u636e\u90fd\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u4efb\u610f\u7684Web\u4e2d\u7684\u56fe\u50cf\u7c7b\u578b\u90fd\u53ef\u4ee5\u4f5c\u4e3a\u6761\u5f62\u7801\u89e3\u6790\u7684\u56fe\u5f62\u53c2\u6570\u3002<\/p>\n<p>\u4e0b\u9762\u770b\u4e0b\u771f\u5b9e\u7684\u6f14\u793a\u7ed3\u679c\u3002<\/p>\n<h3>\u4e8c\u3001\u6848\u4f8b\u6f14\u793a\u4e0e\u652f\u6301\u60c5\u51b5<\/h3>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202301\/js-parse-qrcode-demo.php\" rel=\"noopener\" target=\"_blank\">\u7eafJS\u89e3\u6790\u4e8c\u7ef4\u7801\u56fe\u7247demo<\/a><\/p>\n<p>\u5927\u5bb6\u53ef\u4ee5\u4e0a\u4f20\uff0c\u6216\u8005\u7c98\u8d34\u4efb\u610f\u7684\u4e8c\u7ef4\u7801\u56fe\u50cf\u8fdb\u884c\u6d4b\u8bd5\u3002<\/p>\n<p>\u6216\u8005\uff0c\u4f60\u53ef\u4ee5\u4e16\u754c\u4f7f\u7528demo\u9875\u9762\u63d0\u4f9b\u7684\u4e8c\u7ef4\u7801\u7d20\u6750\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/20230107-113115min.png\" width=\"557\" height=\"512\" alt=\"\u590d\u5236\u5185\u7f6e\u4e8c\u7ef4\u7801\u56fe\u7247\u793a\u610f\" class=\"alignnone size-medium\" style=\"border:1px solid #ddd\" \/><\/p>\n<p>\u6b64\u65f6\uff0c\u518d\u70b9\u51fb\u201c\u8bc6\u522b\u201d\u6309\u94ae\uff0c\u5c31\u53ef\u4ee5\u77e5\u9053\u6b64\u4e8c\u7ef4\u7801\u5bf9\u5e94\u7684\u4fe1\u606f\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/20230107-113407min.png\" width=\"626\" height=\"271\" alt=\"\u8bc6\u522b\u7ed3\u679c\u793a\u610f\" class=\"alignnone size-medium\" style=\"border:1px solid #ddd\" \/><\/p>\n<h4>\u5982\u679c\u4f60\u7684Chrome\u4e0d\u652f\u6301\uff1f<\/h4>\n<p>\u5982\u679c\u60a8\u53d1\u73b0\u4f60\u5f53\u524d\u6d4f\u89c8\u5668\u663e\u793a\u7684\u662f\u4e0d\u652f\u6301 BarcodeDetector\uff0c\u770b\u770b\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u662f\u4e0d\u662fWindows\u7cfb\u7edf\uff0c\u76ee\u524d\uff0c\u6b64\u7279\u6027\u4ec5\u5728 OS X\u7cfb\u7edf\u4e0b\u7684Chrome\u6d4f\u89c8\u5668\u4ee5\u53caAndroid\u64cd\u4f5c\u7cfb\u7edf\u7684Chrome\u4e0b\u652f\u6301\uff0c\u622a\u56fe\u793a\u610f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/2023-01-07_114145.png\" width=\"679\" height=\"496\" alt=\"BarcodeDetector\u517c\u5bb9\u6027\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u81f3\u4e8eSafari\u6d4f\u89c8\u5668\u4ec0\u4e48\u65f6\u5019\u652f\u6301\u8fd9\u4e00\u7279\u6027\uff0c\u6211\u4f30\u8ba1\uff0c\u81f3\u5c11\u8fd8\u6709\u4e00\u4e24\u5e74\u65f6\u95f4\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u76ee\u524d\u8981\u60f3\u5728\u751f\u4ea7\u73af\u5883\u5bf9\u4e8c\u7ef4\u7801\u8fdb\u884c\u89e3\u6790\uff0c\u8fd8\u662f\u9700\u8981\u501f\u52a9\u7b2c\u4e09\u65b9\u7684JS\u5de5\u5177\uff0c\u6bd4\u65b9\u8bf4\u8fd9\u4e2aGithub\u9879\u76ee\uff1a<a href=\"https:\/\/github.com\/cozmo\/jsQR\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/cozmo\/jsQR<\/a><\/p>\n<p>\u53ef\u4ee5\u7eafJS\u4ee3\u7801\u89e3\u6790\u4e8c\u7ef4\u7801\uff0c\u4f7f\u7528\u793a\u610f\uff1a<\/p>\n<pre>const code = jsQR(imageData, width, height, options?);\r\n\r\nif (code) {\r\n  console.log(\"\u627e\u5230QR code\u4e86\", code);\r\n}<\/pre>\n<h3>\u4e09\u3001\u6761\u5f62\u7801\u4e8c\u7ef4\u7801\u7684\u751f\u6210<\/h3>\n<p>\u8fd9\u91cc\uff0c\u518d\u4ecb\u7ecd\u4e0b\u5982\u4f55\u7eaf\u524d\u7aef\u751f\u6210\u6761\u5f62\u7801\uff0c\u6216\u8005\u4e8c\u7ef4\u7801\u3002<\/p>\n<ul>\n<li>\u5173\u4e8e\u6761\u5f62\u7801\u7684\u751f\u6210\uff0c\u6211\u4e4b\u524d\u4e13\u95e8\u5199\u8fc7\u6587\u7ae0\u4ecb\u7ecd\uff0c\u53c2\u89c1\uff1a\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2022\/05\/js-barcode\/\">JS\u4e0e\u6761\u5f62\u7801\u7684\u751f\u6210<\/a>\u201d\uff0c\u4f7f\u7528\u7684\u662f\u8fd9\u4e2a\u9879\u76ee\uff1a<a href=\"https:\/\/github.com\/lindell\/JsBarcode\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/lindell\/JsBarcode<\/a><\/li>\n<li>\u81f3\u4e8e\u4e8c\u7ef4\u7801\u7684\u751f\u6210\uff0c\u53ef\u4ee5\u4f7f\u7528QRCode.js\uff0c\u9879\u76ee\u5730\u5740\uff1a<a href=\"https:\/\/github.com\/davidshimjs\/qrcodejs\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/davidshimjs\/qrcodejs<\/a><\/li>\n<\/ul>\n<p>\u5982\u679c\u4f60\u662f\u5e0c\u671b\u4e0b\u8f7d\u65e0\u6c34\u5370\u7684\u5e72\u51c0\u7684\u4e8c\u7ef4\u7801\uff08\u4f8b\u5982\u5e0c\u671b\u5f04\u4e00\u4e2a\u4e0a\u9762demo\u9875\u9762\u89e3\u6790\u6240\u9700\u7684\u7684\u4e8c\u7ef4\u7801\u56fe\u7247\uff09\uff0c\u4e5f\u53ef\u4ee5\u8bd5\u8bd5\u6211\u81ea\u5df1\u505a\u7684\u4e2a\u5c0f\u5de5\u5177\u9875\u9762 &#8211; \u201c<a href=\"https:\/\/www.zhangxinxu.com\/sp\/qrcode.html\" rel=\"noopener\" target=\"_blank\">\u5728\u7ebf\u8f6c\u4e8c\u7ef4\u7801\u5c0f\u5de5\u5177<\/a>\u201d\uff1ahttps:\/\/www.zhangxinxu.com\/sp\/qrcode.html<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/2023-01-07_121824.png\" width=\"480\" height=\"148\" alt=\"\u4e8c\u7ef4\u7801\u751f\u6210\u5c0f\u5de5\u5177\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u597d\uff0c\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u5168\u90e8\u5185\u5bb9\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86\u4e0b\u5168\u65b0\u7684BarcodeDetector\u8fd9\u4e2a\u539f\u751f\u6761\u7801\u89e3\u6790API\uff0c\u5c55\u793a\u4e86\u51e0\u4e2a\u4e0e\u6761\u5f62\u7801\u4e8c\u7ef4\u7801\u7f16\u7801\u89e3\u7801\u76f8\u5173\u7684Github\u5f00\u6e90\u9879\u76ee\u3002<\/p>\n<p>\u5e0c\u671b\u80fd\u591f\u5bf9\u5927\u5bb6\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u4e5f\u6b22\u8fce\u5927\u5bb6\u8f6c\u53d1\uff0c<button onclick=\"shareWeixin.click()\" class=\"entry-share-btn\">\u5206\u4eab<\/button>\u4e0e\u70b9\u8d5e\uff08\u5982\u679c\u6709\uff09\u3002<\/p>\n<p>???<\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10678\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10678<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202301\/qrcode-cover.png\" width=\"160\" height=\"99\" alt=\"qrcode\u5c01\u9762\u56fe\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>\u4eca\u5929\u624d\u77e5\u9053\uff0c\u539f\u6765\u6d4f\u89c8\u5668\u6709\u539f\u751f\u7684API\uff0c\u53ef\u4ee5\u5bf9\u4e8c\u7ef4\u7801\u3001\u6761\u5f62\u7801\u8fdb\u884c\u89e3\u6790\uff0c\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1284],"tags":[1888,53,1889,1890,1830,75,1829,218,1749],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10678"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=10678"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10678\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=10678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=10678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=10678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}