[英]phonegap barcode scanner plugin -> Reference Error
Can somebody help me with this: When I try to run the project, this is my code in the index.html`s head: 有人可以帮我这一点:当我尝试运行该项目,这是我在index.html`s头代码:
<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). 它在正确的文件夹(项目/资产/ WWW)。 Somebody would help with this, would be great. 有人会解决这个问题,将是巨大的。 thanks 谢谢
edit: 编辑:
The line wich causes the problem in the barcodescanner.js says the following: 该行夹在条形码scanner.js中导致该问题,原因如下:
PhoneGap.addConstructor(function() {
PhoneGap.addPlugin('barcodeScanner', new BarcodeScanner());
}); });
我认为问题在于,您尚未在maain HTML文件中为phonegap-XX.js指定正确的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.