2016-04-30 7 views
1

デフォルトのPhonegapバーコードスキャナートラフプラグインの基本インストールを作成しようとしましたが、うまく機能しませんでした。私は何が起こっているのか分からない。私のコードは以下の通りです:Phonegap barcode scanner:実行できません

var app = { 
    // Application Constructor 
    initialize: function() { 
    this.bindEvents(); 
    }, 
    // Bind Event Listeners 
    // Bind any events that are required on startup. Common events are: 
    // 'load', 'deviceready', 'offline', and 'online'. 
    bindEvents: function() { 
    document.addEventListener('deviceready', this.onDeviceReady, false); 
    }, 
    // deviceready Event Handler 
    // The scope of 'this' is the event. In order to call the 'receivedEvent' 
    // function, we must explicitly call 'app.receivedEvent(...);' 
    onDeviceReady: function() { 
    app.receivedEvent('deviceready'); 
    }, 
    // Update DOM on a Received Event 
    receivedEvent: function(id) { 
    var parentElement = document.getElementById(id); 
    var listeningElement = parentElement.querySelector('.listening'); 
    var receivedElement = parentElement.querySelector('.received'); 
    listeningElement.setAttribute('style', 'display:none;'); 
    receivedElement.setAttribute('style', 'display:block;'); 
    console.log('Received Event: ' + id); 
    console.log('-'); 
    console.log(cordova); 
    console.log('-'); 
    console.log(cordova.plugins.barcodeScanner); 
    console.log('-'); 
    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); 
     } 
    ); 
    } 
}; 

これは基本的にはデフォルトのPhonegapプラグインパネルです。問題は、それがcordova.plugin.barcodeScannerを認識しないことです。 Phonegap Windowsツールを使ってプロジェクトを作成し、フォルダ内でcordova plugin add cordova-plugin-statusbarコマンドを実行しました。私が助けてください、私はこの作業のコード例を見ることができません。ありがとう。

答えて

1

あなたは、

+0

何も起こりません。.. Read More Here

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

はそのが働いていないなら、私に知らせてJavaScriptでgetScanner()関数onClickイベントを呼び出すことができ、私の事、これが私のプロジェクトのいくつかのmissconfigurationであってもよいこと、 http://www.filedropper.com/homemarket <私のプロジェクトをアップロードしました。ウィンドウ用のphonegapツールを使用してビルドし、githubツールの指示に従ってインストールしました –

関連する問題