[Vuejs]-Reading a barcode with javascript

1👍

onInput runs every time the value changes. Most barcode scanners will simulate keypresses to enter the values they scan, so as far as your app is aware, each digit is a keypress that’s changing the value and so it reports each as an input event. An input event’s data property is just the part of the input that’s changed — so you’re getting one at a time.

You need a way to determine when the input is finished, not whenever it happens. I believe most barcode scanners will simulate pressing ENTER or TAB after a full scan is complete, so that might be what you want to detect, not with an input event, but with a keypress or keyup event.

Leave a comment