Currently, I am facing an issue with my barcode gun scanner. It reads barcodes into input fields but returns each digit separately instead of as a whole string. This has been quite bothersome for me.
For instance, when I scan the barcode of a bottle of water, the input field captures the number accurately (e.g., 688267022760). However, upon console logging it, I find that I receive individual instances for every digit.
https://i.sstatic.net/NBuAM.png
In my VueJS template, I have set up the scanner event to trigger on input. I am unsure if this is the correct event and have experimented with keydown and keyup as well. Also, I am uncertain about the recommended event listener for a scanning gun. Here's what I currently have in my template:
<input id="packageInput" type="text" @input="onBarcodeScanned" />
And in my script:
onBarcodeScanned(barcode) {
let numbers = barcode.data;
console.log(numbers);
let newarr = [];
for (var i = 0; i < numbers; i++) {
newarr.push(numbers);
}
},
The desired outcome is to store those individual values in an array and then join them together as a string.
P.S.
After analyzing the barcode property, I found that it consists of multiple objects with handlers for various functions. The property 'data' is what I am interested in. Below is an example of the barcode objects https://i.sstatic.net/XjZy3.png
I am puzzled about how to go about solving this issue
P.P.S I am aware that the scanner itself comes with programming instructions, some of which are unclear to me. Could there be a certain type of barcode that returns as a string rather than individual digits as objects? The scanner model I am using is a Wasp CCDScanner WCS3900