【问题标题】:QRScanner - After scan router navigate dosen't workQRScanner - 扫描路由器后导航不起作用
【发布时间】:2018-11-17 20:58:22
【问题描述】:

我在 Angular 项目中遇到了 cordova-plugin-qrscanner 的问题。在我的组件中,我扫描 QR 码,如果扫描完成,我想导航到另一个组件。 不幸的是,它不能正常工作。这是我的代码的一部分

 scan() {

     // QRScanner.prepare();
     const that = this;

      QRScanner.show();
     window.document.querySelector('body').classList.remove('transparentBody');
      QRScanner.scan(displayContents);



     function displayContents(err, text) {
      if(err){
        console.log('error', err);
        // an error occurred, or the scan was canceled (error code `6`)
      } else {
        // The scan completed, display the contents of the QR code:
         alert(text);
this._router.navigate(['/main/depositor']);  // here dosen't work
        if (text) {`enter code here`
          QRScanner.destroy((status) => {
            console.log('destroy scanner', status);
         window.document.querySelector('body').classList.add('transparentBody');
this._router.navigate(['/main/depositor']);  // here too dosen't work
          });
        }
      }
    }
  }

有人有类似的问题吗?在我的手机应用程序上导航后退出或什么都不做。我不知道出了什么问题

【问题讨论】:

    标签: android angular cordova cordova-plugins


    【解决方案1】:
    1. 检查控制台是否有错误。如果有的话

      如果(错误){

    这将是真的,并且没有路由器导航。

    1. 检查路径“/main/depositor”的拼写是否存在

    【讨论】:

    • 1.控制台 2 中没有错误。路径是正确的(我使用相同的导航创建方法并且它可以工作)我认为 qrscanner.destroy 之后有问题,但我不知道为什么它不起作用
    • 我认为 QRScanner.show();需要在 QRScanner.scan(displayContents) 之后添加;查看文档
    • 不幸的是这无济于事:(
    猜你喜欢
    • 1970-01-01
    • 2019-09-10
    • 2017-04-06
    • 2016-04-24
    • 2018-07-04
    • 2019-08-01
    • 2018-09-04
    • 1970-01-01
    相关资源
    最近更新 更多