cordova插件条码扫描器不打开扫描 [英] cordova plugin barcode scanner doesn't open the scan

查看:978
本文介绍了cordova插件条码扫描器不打开扫描的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的条码扫描器插件有问题(我不是天才,我不知道如何编程的网络应用程序。)。

我使用phonegap和cordova和我试图做一个网页应用程序,点击链接后扫描条形码。

我安装了插件,在此命令行之前:

I have a problem with the barcode scanner plugin (I'm not a genius and I don't know well how to programm a web-app.).
I use phonegap and cordova and I've tried to do a web-app that scan a barcode after a click on a link.
I've installed the plugin, before with this command line:

cordova plugin add cordova-plugin-barcodescanner

我写这个js代码:

and I write this js code:

function scan(){
 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);
  }
 );
}

<a href="javascript:void(0);" onclick="scan()">Scan</a>

但是当我点击链接时,不会发生任何事。

如果我在之后发出警告:function scan(){,它显示
如果我在其后提出警告:cordova.plugins.barcodeScanner.scan(,不做任何事情。

所以,我试图卸载插件,并安装它与这个命令行:

But when I click on the link, It doesn't happen anything.
If I put an alert after: function scan(){, it show if I put an alert after: cordova.plugins.barcodeScanner.scan(, doesn't do anything.
So, I tried to uninstall the plugin and install it with this command line:

cordova plugin add com.phonegap.plugins.barcodescanner

使用相同的js和html代码,但它还不起作用。

所以,我卸载插件,并尝试安装它:

With the same js and html code, but it doesn't work yet.
So, I uninstall the plugin and I try to install it with:

cordova plugin add https://github.com/wildabeast/BarcodeScanner.git

但还有什么呢
我搜索了很多,我尝试了很多解决方案!

我使用cordova 5.0.0,我尝试在android 4.4和IOS插件。

我也安装了插件摄像头
所以,请帮助我!错误在哪里?

我遵循我在网络上和stackoverflow上找到的所有解决方案。

代码总是崩溃之后:

But anything yet. I search a lot and I try a lot of solutions!
I use cordova 5.0.0 and I try the plugin on android 4.4 and IOS.
I also installed the plugin camera. So, please, help me! Where is the error?
I followed all the solutions that I've find on the web and on stackoverflow.
The code always crashes after:

cordova.plugins.barcodeScanner.scan(

任何人都可以帮助我吗?
非常感谢。

Can anyone help me, please? Thank you so much.

推荐答案

首先,您可以使用firebug检查firefox中的代码,正在给出一些错误,可以让你这样做,或者你可以尝试其他库,是intelXDK

First of all can you check your code in firefox with firebug, see if it is giving some error which can let you to do so or you can try other library which is intelXDK

document.addEventListener("intel.xdk.device.barcode.scan",function(evt){});

这篇关于cordova插件条码扫描器不打开扫描的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆