-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
28 lines (26 loc) · 992 Bytes
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
</head>
<body>
<button id="btn1">test create scanner</button><br>
<button id="btn2">test One function directly scanning</button><br>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dbr.bundle.js"></script>
<script src="./dist/easy-barcode-scanner.js" data-license=""></script>
<script>
let pScanner, scanner;
document.getElementById('btn1').addEventListener('click',async()=>{
scanner = await (pScanner || (pScanner = EasyBarcodeScanner.createInstance()));
scanner.onUniqueRead = (txt) => { console.log(txt); };
await scanner.open();
});
document.getElementById('btn2').addEventListener('click',async()=>{
let txt = await EasyBarcodeScanner.scan('./easy-barcode-scanner.ui.html?v=2');
alert(txt);
});
</script>
</body>
</html>