2015-10-16 28 views
0

我使用phonegap生成版本cli-5.2.0和barcodescanner插件。Phonegap生成cli-5.2.0 - 插件barcodescanner沒有觸發

我已經添加插件到config.xml:

然後在我的index.html頁面,我說:

<script> 
function clickScan() { 

alert('tester'); 

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); 
     } 
    ); 


}; 
</script> 

然後一個按鈕:

<button onclick="clickScan();">Scan</button> 

警報即將出現,但掃描儀未打開。

我在做什麼錯在這裏?

回答

0

我明白了。

我不得不添加:

<script src="phonegap.js"></script> 
<script src="barcodescanner.js"></script> 

到index.html頁面。這解決了我的情況。

相關問題