방금 같은 문제에 직면했습니다. 여기에 제가 생각해 낸 해결 방법이 있습니다.
요약하면 : 코드가 성공적으로 반환 될 때마다 검색된 정보를 배열에 저장하고 즉시 검색을 다시 시작합니다.
이
내가 간단한 유성 응용 프로그램 내에서 내 해결 방법을 테스트하는 데 사용하는 코드입니다 : 그것은 위의 80prozet 솔루션 @ 사용하여 근무하고있다
// list to collect successfully scans
var scanned_list=[];
// callback function that will be executed everytime barcodescanner.scan ends without error
scannedOneItem = function (result) {
// user cancelled the scan: now check if we have something scanned already or not:
if(result.cancelled){
if(scanned_list.length>0){
// no items scanned, user cancelled
alert("Scanned items: " + scanned_list.length);
}
else{
alert("Scanned canceled");
}
}
// a item was scanned successfully - add it to list, and restart barcodescanner
else{
scanned_list.append(result.text);
cordova.plugins.barcodeScanner.scan(
scannedOneItem,
function (error) {
alert("Scanning failed: " + error);
}
);
}
}
Template.barcode_scanner.events({
'click button': function() {
// start scanning when button is pressed:
cordova.plugins.barcodeScanner.scan(
scannedOneItem,
function (error) {
alert("Scanning failed: " + error);
}
);
}
});