条形码扫描仪失败了phonegap

时间:2014-03-13 13:29:45

标签: cordova barcode

当我尝试启动扫描仪时出现错误。

<script type="text/javascript" src="js/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.4.2.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="barcodescanner.js"></script>
<script type="text/javascript" src="childbrowser.js"></script>
<script type="text/javascript" src="js/index.js"></script>

这是错误。

enter image description here

这是我的javascript代码。我从phonegap中获取条形码扫描器的示例代码。

scan : function() {
        console.log('scanning');
        var scanner = cordova.require("cordova/plugin/BarcodeScanner");
        scanner.scan(function(result) { 
            alert("We got a barcode\n" + "Result: " + result.text + "\n"
                    + "Format: " + result.format + "\n" + "Cancelled: "
                    + result.cancelled);

            console.log(result);
        }, function(error) {
            console.log("Scanning failed: ", error);
        });

我找不到解决此问题的方法

修改 是否可以上传或复制粘贴config.xml文件?

2 个答案:

答案 0 :(得分:0)

检查你的config.xml。确保添加此phonegap插件条形码扫描器。

答案 1 :(得分:0)

好的,这对我很有用。

<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns   = "http://www.w3.org/ns/widgets"
xmlns:gap   = "http://phonegap.com/ns/1.0"
id          = "com.phonegap.example"
versionCode = "10" 
version     = "1.0.0" >

<!-- versionCode is optional and Android only -->

<name>PhoneGap Example</name>

<description>
  An example for phonegap build docs. 
</description>

<author href="https://build.phonegap.com" email="support@phonegap.com">
  Hardeep Shoker 
</author>

<!-- We'll include the Barcode plugin as an example -->
<gap:plugin name="com.phonegap.plugins.barcodescanner" />