QRScanner-扫描路由器导航后无法正常工作

时间:2018-11-17 20:58:23

标签: android angular cordova cordova-plugins

我在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
          });
        }
      }
    }
  }

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

1 个答案:

答案 0 :(得分:0)

  1. 检查控制台是否有错误。如果意味着

    if(err){

这是正确的,并且没有路由器导航。

  1. 检查路径“ / main / depositor”的拼写以及是否存在
相关问题