通过@zxingngx-scanner扫描CODE_128格式的条码时出现错误。

问题描述 投票:0回答:1

我使用的是 @zxingngx-scanner 来扫描条码。我可以用笔记本相机扫描QR_CODE和DATA_MATRIX格式的条码。现在我想扫描CODE_128格式的条码。但是库扫描需要时间,而且扫描的时候...扫描不正确。

有人遇到过类似的问题吗?我该如何纠正这个问题?

我使用的是Angular 7和ngx-scanner 2.0.1版本,我在Windows 10的Chrome浏览器中尝试。

编码:我是用Angular 7和ngx-scanner版本2.0.1.我在Windows 10的Chrome浏览器上尝试。

In HTML:
<zxing-scanner #scanner start="true" (scanSuccess)="myFn($event)" [formats]="['QR_CODE', 'EAN_13', 'CODE_128', 'DATA_MATRIX']"></zxing-scanner>
In ts:
import { ZXingScannerComponent } from '@zxing/ngx-scanner';

export class myClass implements OnInit {
 @ViewChild('scanner') scanner: ZXingScannerComponent;
 hasDevices: boolean = false;
 hasPermission: boolean;
 availableDevices: MediaDeviceInfo[] = [];
 currentDevice: MediaDeviceInfo;

 constructor(private zone: NgZone) {
  window['angularComponentReference'] = {
    zone: this.zone,
    componentFn: (searchcontent: any) =>
      window['scannerOutput'](searchcontent),
      component: this,
  };
 }

 ngOnInit() {
  this.scanner.camerasFound.subscribe((devices: MediaDeviceInfo[]) => {
     this.hasDevices = true;
     this.availableDevices = devices;
  });
  this.scanner.camerasNotFound.subscribe(() => {
     this.hasDevices = false;
  });
  this.scanner.scanComplete.subscribe((result: Result) => {
     this.qrResult = result;
     this.hasPermission = false;
  });
  this.scanner.permissionResponse.subscribe((perm: boolean) => {
    this.hasPermission = perm;
  });
 }

 myFn(resultString) {
   console.log(resultString);
 }

}

更新:我需要扫描的条形码样本enter image description here

angular angular7 zxing barcode-scanner
1个回答
0
投票

这个问题已经解决了。对于一维条码,我们需要水平拿着条码才能正确扫描。

更多信息,我已经创建了github问题。https:/github.comzxing-jsngx-scannerissues296。

© www.soinside.com 2019 - 2024. All rights reserved.