0

Phonegap Build로 jQuery Mobile 앱을 빌드 할 때 Phonegap Build Barcode Scanner Plugin을 사용하려고합니다. 작동하지 않습니다.Phonegap Build : Barcode Scanner Plugin이 작동하지 않습니다.

$(document).on('pageshow', '#page_sample', function(e) {  
     $('#scan').click(function() { 
      alert('scanning'); 

      var scanner = cordova.require("cordova/plugin/BarcodeScanner"); 

      alert(scanner); 

      scanner.scan(function (result) { 
       alert("We got a barcode\n" + 
       "Result: " + result.text + "\n" + 
       "Format: " + result.format + "\n" + 
       "Cancelled: " + result.cancelled); 

       alert("Scanner result: \n" + 
        "text: " + result.text + "\n" + 
        "format: " + result.format + "\n" + 
        "cancelled: " + result.cancelled + "\n"); 
       alert(result); 
      },function (error) { 
       console.log("Scanning failed: ", error); 
      }); 
     }); 
    }); 

내 config.xml 파일 :

<!-- Barcode Scanner --> 
<gap:plugin name="com.phonegap.plugins.barcodescanner" version="1.0.2" /> 

나는이이 파일 codiqa.ext.js에서

<!DOCTYPE html> 
<html lang="pt-br"> 
<html> 
<head> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, maximum-scale=1"> 
    <meta name="apple-mobile-web-app-capable" content="yes"> 
    <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
    <title>Save Points</title> 

    <!-- CSS --> 
    <link rel="stylesheet" href="css/jquery.mobile-1.3.1.min.css"> 
    <link rel="stylesheet" href="css/themes/savepoints.min.css" /> 
    <link rel="stylesheet" href="css/codiqa.ext.css"> 

    <!-- jQuery and jQuery Mobile --> 
    <script type="text/javascript" src="phonegap.js"></script> 
    <script type="text/javascript" src="barcodescanner.js"></script> 
    <script src="js/jquery-1.9.0.js"></script> 
    <script src="js/codiqa.ext.js"></script> 
    <script src="js/jquery.mobile-1.3.1.min.js"></script> 
</head> 
<body> 
<div data-role="page" id="page_sample" data-theme="a">  
    <div data-role="content"> 
     <div id="content">  
      <p><a href="#" class="topcoat-button" id="scan">SCAN</a></p> 
      <p><a href="#" class="topcoat-button" id="encode">ENCODE</a></p> 
     </div> 
    </div> 
</div> 
</body> 
</html> 

: 여기

나는 샘플 페이지가 이 코드를 디버깅하면서 스크립트가 다음 줄에서 멈추는 것을 알았습니다.

var scanner = cordova.require("cordova/plugin/BarcodeScanner"); 

나는 프로젝트에 barcodescanner.js 파일을 넣을 필요가 없다는 공식 문서를 따르고 있지만, html 헤더에는 참조 만하고있다.

내가 잘하고 있는지 아는 사람이 있습니까?

미리 감사드립니다.

는 문제가 해결

UPDATED! 나는

<preference name="phonegap-version" value="3.0.0" /> 

대신

<preference name="phonegap-version" value="2.9.0" /> 

답변

0

문제가 해결 사용해야합니다!

나는

<preference name="phonegap-version" value="3.0.0" /> 

대신

<preference name="phonegap-version" value="2.9.0" /> 
사용해야합니다
관련 문제