在安卓浏览器上使用Ionic QRScanner的问题:放大太多。

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

我用的是 https:/ionicframework.comdocsnativeqr-scanner。 在浏览器的Ionic 4Angular应用中。

该应用在笔记本浏览器上运行良好,可以让摄像头预览和读取二维码。

但是,在Android浏览器上尝试时,摄像头放大太多,无法扫描代码。

在互联网上,并没有什么(只是有人要求在插件中加入放大缩小功能),我尝试通过另一个插件来控制摄像头的放大(https:/ionicframework.comdocsnativecamera-preview。)但是没有用。

有人知道如何解决这个问题吗?

我把我的代码附在这条信息的末尾,以供参考。

谢谢。

  scanCode() {
    console.log('entering scan function');
    this.qrScanner.prepare()
    .then((status: QRScannerStatus) => {
      console.log('checking status');
       if (status.authorized) {
         this.statusScanning=true;
         // camera permission was granted
         console.log('camera permission granted');
         // start scanning
         this.scanSub = this.qrScanner.scan().subscribe( (scanRes: string) => {
          let object:any=scanRes;
          if(isDefined(object.result))
          {
            let text: string=""+object.result;
            this.myfunction(text);
            this.qrScanner.hide(); // hide camera preview
            this.scanSub.unsubscribe(); // stop scanning
          }
         });
       } else if (status.denied) {
         // camera permission was permanently denied
         // you must use QRScanner.openSettings() method to guide the user to the settings page
         // then they can grant the permission from there
         console.log('status denied');
       } else {
        console.log('permissions denied for now');
         // permission was denied, but not permanently. You can ask for permission again at a later time.
       }
    })
    .catch((e: any) => console.log('Error:', e));
  }
android browser ionic4 qr-code
1个回答
0
投票

以防有人遇到和我一样的问题,我发现最好的选择就是放弃QRScanner组件,使用jsQR.我遵循了本页教程中的原则(https:/devdactic.compwa-qr-scanner-ionic。),最后一切工作正常。

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