42 lines
766 B
Svelte
42 lines
766 B
Svelte
<style>
|
|
.error {
|
|
color: darkred;
|
|
}
|
|
</style>
|
|
<script>
|
|
import {Html5QrcodeScanner} from "html5-qrcode";
|
|
|
|
function onScanSuccess(decodedText, decodedResult) {
|
|
console.log('Code matched ' + decodedResult);
|
|
document.getElementById("log").prepend(decodedText);
|
|
}
|
|
|
|
function onScanFailure(error) {
|
|
}
|
|
|
|
function scanner() {
|
|
let html5QrcodeScanner = new Html5QrcodeScanner("reader", {
|
|
fps: 10,
|
|
qrbox: {width: 250, height: 250}
|
|
}, /* verbose */ false);
|
|
|
|
html5QrcodeScanner.render(onScanSuccess, onScanFailure);
|
|
}
|
|
</script>
|
|
|
|
|
|
<div className="container">
|
|
<div class="row">
|
|
Hello World!
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div use:scanner id="reader" width="300px"></div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div id="log" class="col-12">
|
|
</div>
|
|
</div>
|
|
</div>
|