已安装Cordova条形码扫描仪,但出现错误会触发扫描仪

时间:2018-05-23 10:04:45

标签: meteor cordova-plugins barcode-scanner

任何人都有使用此Cordova / Phonegap插件的经验吗?

https://github.com/phonegap/phonegap-plugin-barcodescanner

我使用以下命令安装插件:meteor add cordova:phonegap-plugin-barcodescanner@6.0.8

然后meteor run android-device

我从shell看到该插件已下载并安装。但是当我点击触发以下示例代码的按钮时:

cordova.plugins.barcodeScanner.scan(
      function (result) {
          alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
      },
      function (error) {
          alert("Scanning failed: " + error);
      },
      {
          preferFrontCamera : true, // iOS and Android
          showFlipCameraButton : true, // iOS and Android
          showTorchButton : true, // iOS and Android
          torchOn: true, // Android, launch with the torch switched on (if available)
          saveHistory: true, // Android, save scan history (default false)
          prompt : "Place a barcode inside the scan area", // Android
          resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
          formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
          orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
          disableAnimations : true, // iOS
          disableSuccessBeep: false // iOS and Android
      }
   );

我从shell声明中得到错误:

"Uncaught TypeError: Cannot read property 'barcodeScanner' of undefined"

请帮助提供有关如何成功使用插件的一些提示或指导?请帮助,谢谢。

0 个答案:

没有答案