phonegap barcode scanner plugin -> Reference Error

时光毁灭记忆、已成空白 提交于 2019-12-25 05:13:34

问题


Can somebody help me with this: When I try to run the project, this is my code in the index.html`s head:

    <script type="text/javascript" src="barcodescanner.js"></script>
<script type="text/javascript" src="main.js"></script>

<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript">
    function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}


// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
    window.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>

I get the following error:

11-05 12:22:23.641: E/Web Console(454): ReferenceError: Can't find variable: PhoneGap at file:///android_asset/www/barcodescanner.js:57

the file is from the bar code scanner plugin. Its in the correct folder (project/assets/www). Somebody would help with this, would be great. thanks

edit:

The line wich causes the problem in the barcodescanner.js says the following:

PhoneGap.addConstructor(function() {
PhoneGap.addPlugin('barcodeScanner', new BarcodeScanner());

});


回答1:


I think the issue is that, you have not specified the correct path for your phonegap-XX.js in your maain HTML file.



来源:https://stackoverflow.com/questions/8019897/phonegap-barcode-scanner-plugin-reference-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!