Zxing 扫描程序组件: 类型错误类型错误: 无法读取未定义的属性'stop'



我正在尝试扫描文档以获取数据。我正在使用Zxing扫描仪,我得到了错误和相机电源关闭。有一些类似的停顿,但答案对我没有帮助。

我的代码:

import { Component } from '@angular/core';

@Component({
selector: 'app-scanner',
templateUrl: './scanner.component.html',
styleUrls: ['./scanner.component.css']
})
export class ScannerComponent {
constructor() { }
camerasNotFound(e: Event) {
// Display an alert modal here
}
cameraFound(e: Event) {
// Log to see if the camera was found
}
onScanSuccess(result: string) {
console.log(result);
}
scanSuccessHandler(e: Event): void {
}
}

模板是:

<zxing-scanner
#scanner
[formats]="['QR_CODE', 'EAN_13']"
(camerasFound)="cameraFound($event)"
(camerasNotFound)="camerasNotFound($event)"
(scanSuccess)="scanSuccessHandler($event)"
>
</zxing-scanner>

我在这个链接中做了如下操作:https://github.com/zxing-js/ngx-scanner/wiki/Getting-Started

您必须确保安装最新或相同版本的浏览器&库

"zxing/浏览器":"0.0.9";,"zxing/库":"0.18.6〃;,

试试这个

npm i @zxing/browser@0.0.9 --save --legacy-peer-deps
npm i @zxing/library@0.18.6 --save --legacy-peer-deps
npm i @zxing/ngx-scanner@3.2.0 --save --legacy-peer-deps

相关内容

  • 没有找到相关文章

最新更新