1. 程式人生 > >前端二維碼掃描庫html5-qrcode使用

前端二維碼掃描庫html5-qrcode使用

本文介紹前端二維碼掃描庫html5-qrcode的使用。

一、庫文件及原始碼

二、引入庫檔案

需要引入的庫檔案如下:

這裡寫圖片描述

三、建立容器

 <div id="reader" style="width:300px;height:250px">
 </div>

注意:這裡必須指定容器大小。

四、掃描處理函式實現

$('#reader').html5_qrcode(function(data){
         // do something when code is read
         alert(data);
    },
    function
(error){
//show read errors alert(error); }, function(videoError){ //the video stream could be opened alert(videoError); } );