You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
555 B
27 lines
555 B
<script>
|
|
import BarcodeDetector from "barcode-detector"
|
|
|
|
export default {
|
|
beforeMount() {
|
|
// if (!('BarcodeDetector' in window)) {
|
|
window.BarcodeDetector = BarcodeDetector
|
|
// }
|
|
},
|
|
|
|
methods: {
|
|
async onDetect(resultPromise) {
|
|
this.$emit("detect", resultPromise);
|
|
|
|
try {
|
|
const {content} = await resultPromise;
|
|
|
|
if (content !== null) {
|
|
this.$emit("decode", content);
|
|
}
|
|
} catch (error) {
|
|
// fail silently
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|