我什么环境 插件都搞好了 就是不能进行扫描 请问这是为什么
急急急 希望你们能帮我 谢谢
1、把所需要的.cpp .mm等导入Plugins中 如图
2、在config.xml中加入一段代码 并HTML中进行了引用.jsconfig.xml中
<feature name="BarcodeScanner">
<param name="ios-package" value="CDVBarcodeScanner" />
</feature>
HTML中
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>收件扫描</title> <link href="../jquery-mobile-1.4.5/jquery.mobile-1.4.5.min.css" rel="stylesheet" type="text/css"/> <link href="../scan/scan.css" rel="stylesheet" type="text/css"/> <script src="../jquery-mobile-1.4.5/jquery-1.8.3.min.js" type="text/javascript"></script> <script src="../jquery-mobile-1.4.5/jquery.mobile-1.4.5.min.js" type="text/javascript"></script> <script src="../ cordova.js" type="text/javascript"></script> <script src="../db/db.js" type="text/javascript"></script> <script src="receiverScan.js" type="text/jscript"></script> <script src="Toast.js" type="text/javascript"></script> <script src="barcodescanner.js" type="text/javascript"></script> </head>
3、把js文件导入www包的html文件夹中 (第一个就是)
4、JS代码中 如下
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);
}
);
5、通过try catch 捕获到异常
function loadBill(){
alert("扫描"); try{ var scanner =window.plugins.barcodeScanner scanner.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); } ); }catch(error){ alert(error.message); }
}
我都这样搞了 还是不行 坑啊 ~~~~~~~~ !
|