我正在开发一个 android-phonegap 应用程序,我必须在其中解码我的学生证的条形码和图书馆书籍的条形码。首先我必须通过连接到应用程序的移动摄像头捕获条形码。这是我编写的 .js 代码
扫描码.js
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);
}
);
这是我获取条形码详细信息的 html 文件
洞穴.html
<!DOCTYPE html>
<html>
<head>
<title>Burrow</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.7.0.js"></script>
<script type="text/javascript" charset="utf-8" src="PopUpBox.js"></script>
<script type="text/javascript" src="Connect.js"></script>
<script type="text/javascript" src="BarCode.js"></script>
</head>
<form>
<body>
<FORM>
<INPUT Type="button" style="background-color:#4682B4" VALUE="Back" onClick="history.go(-1);return true;">
</FORM>
<br><br>
<img src="../www/images/pic.jpg" style="width:300px;height:80px;">
<br><br><br>
<center><input type="button" style="background-color:#2F4F4F;width:230px;height:45px;text-align:center;color:#DCDCDC;font-size:1.5em" onClick="window.plugins.barcodeScanner.scan( function(result)" value="Scan Student ID"></center>
<br>
<center><input type="button" style="background-color:#2F4F4F;width:230px;height:45px;text-align:center;color:#DCDCDC;font-size:1.5em" onClick="window.plugins.barcodeScanner.scan( function(result)" value="Scan Book ID"></center>
<br><br>
<center><input type="button" style="background-color:#2F4F4F;width:230px;height:45px;text-align:center;color:#DCDCDC;font-size:1.5em" onClick="Burrow_Confirmation()" value="Burrow"></center><br/>
</body>
</form>
</html>
我根据文档创建了条码扫描器库。我的编码不起作用。你能给出解决方案吗?