2015-07-21 63 views
0

我試圖用barcodescanner插件創建一個簡單的應用程序,但它似乎不會在我嘗試撥打電話後正常啓動。Phonegap Barcodescanner無法啓動功能

Phonegap構建認識到插件和應用程序啓動沒有問題,但該按鈕不會觸發掃描事件。也許barcodescanner甚至可能不會啓動。我不太確定,但在那之前,我應該在啓動應用程序之前得到一個錯誤。

我試着在Android和Windows上測試應用程序,但沒有結果。 我也嘗試過使用較舊版本的phonegap來解決問題。目前我正在使用3.7。

我也嘗試了其他方法,嘗試使用添加插件平臺等來創建/ phonegap創建項目名稱。仍有相同的結果。

我的HTML和JS

document.addEventListener("deviceready", onDeviceReady, false); 
 

 
function onDeviceReady() { 
 
    function scan() { 
 
    \t 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); 
 
     } 
 
    ); 
 
} 
 
}
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
\t <meta charset="UTF-8"> 
 
\t <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> 
 
\t <title>Roargame</title> 
 
</head> 
 
<body> 
 

 
\t <button data-icon="search" onclick="scan()">Scan ME NOW!!!!</button> 
 
\t 
 

 

 
\t <script type="text/javascript" charset="utf-8" src="cordova.js"></script> 
 
\t <script type="text/javascript" charset="utf-8" src="barcodescanner.js"></script> 
 
\t <script type="text/javascript" charset="utf-8" src="js/app.js"></script> 
 
</body> 
 
</html>

我的XML配置

<?xml version='1.0' encoding='utf-8'?> 
 
<widget id="com.testdomain.barcode" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"> 
 
    <name>Roargame</name> 
 
    <description> 
 
     Test barcodescanner 
 
    </description> 
 
    <author email="[email protected]" href="https://testdomain.com"> 
 
     Some Random Name 
 
    </author> 
 
    <content src="index.html" /> 
 
    <gap:plugin name="com.phonegap.plugins.barcodescanner" version="2.2.0" /> 
 
    <icon src="icon.png" /> 
 
</widget>

回答

0

檢查JavaScript控制檯中的錯誤。

+0

我做到了。我害怕沒有錯誤。 也嘗試過一些單元測試。所有積極的。 – Nefiron