小编Ayu*_*ahu的帖子

在 ionic 中实现 QR 扫描仪

我是 ionic 新手,所以我对 Ionic 框架不太了解,我正在尝试实现 Cordova-plugin-QR 扫描仪,但它在我的控制台上显示以下错误。

在此输入图像描述

这是我的代码

import { Component, OnInit } from '@angular/core';
import { QRScanner, QRScannerStatus } from '@ionic-native/qr-scanner/ngx';

@Component({
  selector: 'app-notification',
  templateUrl: './notification.page.html',
  styleUrls: ['./notification.page.scss'],
})

export class NotificationPage implements OnInit {
    constructor(private qrScanner: QRScanner  ) {
    }

ngOnInit(){
  this.qrScanner.prepare()
  .then((status: QRScannerStatus) => {
     if (status.authorized) {
       // camera permission was granted


       // start scanning
       let scanSub = this.qrScanner.scan().subscribe((text: string) => {
         console.log('Scanned something', text);

         this.qrScanner.hide(); // hide camera preview
         scanSub.unsubscribe(); // stop scanning
       });

     } …
Run Code Online (Sandbox Code Playgroud)

qr-code ionic-framework angular

0
推荐指数
1
解决办法
1337
查看次数

标签 统计

angular ×1

ionic-framework ×1

qr-code ×1