【问题标题】:barcode scanner failed phonegap条码扫描仪电话间隙失败
【发布时间】:2023-03-18 09:21:02
【问题描述】:

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

<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>

这是错误。

这是我的 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 文件?

【问题讨论】:

    标签: cordova barcode


    【解决方案1】:

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

    【讨论】:

    • 在 config.xml 文件中
    • 你在使用phonegap构建吗?
    • 你使用什么平台?
    • 我用的是3.1.0版本的phonegap
    • 我的意思是,iOS 还是安卓?
    【解决方案2】:

    好的,这对我很有用。

    <?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" />
    

    【讨论】:

      猜你喜欢
      • 2013-07-09
      • 1970-01-01
      • 1970-01-01
      • 2012-01-03
      • 1970-01-01
      • 2020-11-18
      • 2020-12-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多