前端二维码扫描库html5-qrcode使用

本文介绍前端二维码扫描库html5-qrcode的使用。


一、库文档及源码

https://github.com/dwa012/html5-qrcode


二、引入库文件

需要引入的库文件如下:

前端二维码扫描库html5-qrcode使用_第1张图片


三、创建容器

 <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);
    }
);

你可能感兴趣的:(前端二维码扫描库html5-qrcode使用)