llqrcode js識(shí)別二維碼解析二維碼信息實(shí)例
正文
llqrcode.js具有掃描二維碼功能,用來(lái)進(jìn)行從圖片中識(shí)別二維碼,可解析二維碼的信息。
代碼
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>llqrcode識(shí)別二維碼</title> <script src="llqrcode.js"></script> <script> function getUrl(e,param){ analyticCode.getUrl( param,e,function(url,param){ document.querySelector("#uploadQrcode").style.display = "none"; document.querySelector("#uploadQrcode_preview").innerHTML ="<img src='"+param+"' />"; document.querySelector("#qrcodeUrl").innerHTML ="識(shí)別內(nèi)容:"+ url; document.querySelector("#rescan").style.display = "block"; } ) } let getObjectURL = function(file){ let url = null ; if (window.createObjectURL!=undefined) { url = window.createObjectURL(file) ; } else if (window.URL!=undefined) { url = window.URL.createObjectURL(file) ; } else if (window.webkitURL!=undefined) { url = window.webkitURL.createObjectURL(file) ; } return url ; } window.analyticCode = { getUrl : function(type,elem,fn){ let url = null,src = null; if(type === 'img-url'){ url = elem.src; }else if(type === 'file-url' && elem.files.length > 0){ url = getObjectURL(elem.files[0]); } qrcode.decode(url); qrcode.callback = function(imgMsg){ fn(imgMsg,url); } } } </script> <style> h3{ text-align: center; margin-top: 100px; } #uploadQrcode{ width: 80px; height: 80px; margin:20px auto 0; border: 2px dashed #ccc; border-radius: 20px; font-size: 25px; line-height: 80px; text-align: center; color: #ccc; position: relative; cursor: pointer; } #selectQrcode{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; } #qrcodeUrl{ text-align: center; margin-top: 15px; } #uploadQrcode_preview{ width: 80px; height: 80px; margin:20px auto 0; } #uploadQrcode_preview img{ width: 80px; height: 80px; } #rescan{ text-align: center; text-decoration: none; color: #666; font-size: 15px; margin-top: 15px; display: none; } </style> </head> <body> <h3>選擇一張二維碼圖片</h3> <div id="uploadQrcode"> <span>+</span> <input type="file" id="selectQrcode" onChange="getUrl(this,'file-url')" /> </div> <!-- 圖片預(yù)覽 --> <div id="uploadQrcode_preview"></div> <!-- 識(shí)別結(jié)果 --> <p id="qrcodeUrl"></p> <a href="" id=" rel="external nofollow" rescan">重新識(shí)別</a> </body> </html>
以上就是llqrcode js識(shí)別二維碼解析二維碼信息實(shí)例的詳細(xì)內(nèi)容,更多關(guān)于llqrcode js識(shí)別解析二維碼信息的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
小程序?qū)崿F(xiàn)人臉識(shí)別功能(百度ai)
這篇文章主要介紹了小程序?qū)崿F(xiàn)人臉識(shí)別功能(百度ai),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-12-12教你如何在 Javascript 文件里使用 .Net MVC Razor 語(yǔ)法
文章主要是介紹了通過(guò)一個(gè)第三方類(lèi)庫(kù)RazorJS,實(shí)現(xiàn)Javascript 文件里使用 .Net MVC Razor 語(yǔ)法,很巧妙,推薦給大家2014-07-07IE6,IE7,IE8下使用Javascript記錄光標(biāo)選中范圍(已補(bǔ)全)
IE6,7,8下使用Javascript記錄光標(biāo)選中范圍(已補(bǔ)全)(已解決單個(gè)節(jié)點(diǎn)內(nèi)部重復(fù)字符的問(wèn)題)2011-08-08layui: layer.open加載窗體時(shí)出現(xiàn)遮罩層的解決方法
今天小編就為大家分享一篇layui: layer.open加載窗體時(shí)出現(xiàn)遮罩層的解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09