Cordova 如何将Phonegap插件集成到条形码扫描仪的移动web应用程序中?

Cordova 如何将Phonegap插件集成到条形码扫描仪的移动web应用程序中?,cordova,phonegap-plugins,barcode-scanner,Cordova,Phonegap Plugins,Barcode Scanner,我们正在尝试在我们的移动web应用程序中集成用于条形码扫描仪的phonegap插件。有人能帮我整合一下吗 我添加了Phonegap.js和cardova.js,插件试图安装,但它花费了太多时间,而且没有安装 这是我的HTML内容 <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title

我们正在尝试在我们的移动web应用程序中集成用于条形码扫描仪的phonegap插件。有人能帮我整合一下吗

我添加了Phonegap.js和cardova.js,插件试图安装,但它花费了太多时间,而且没有安装

这是我的HTML内容

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Bar code Reader</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="barcodescanner.js"></script>
<script src="cordova.js"></script>
<script>
$(document).ready(function () {
app.initialize();
});
function clickScan() {
console.log("I am now scanning");
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>
</head>
<body>
<button id="scan" style="padding: 10px;" onclick="clickScan">Scan!</button>
</body>
</html>

条形码阅读器
$(文档).ready(函数(){
app.initialize();
});
函数clickScan(){
log(“我现在正在扫描”);
window.plugins.barcodeScanner.scan(函数(结果){
警报(“我们得到了一个条形码\n”+
结果:“+Result.text+”\n+
格式:“+result.Format+”\n+
“已取消:“+结果.已取消”);
},函数(错误){
警报(“扫描失败:+错误”);
});
}
扫描

遵循以下步骤

1.下载并安装
Node.js

2.在命令提示符下运行此命令
$sudo npm install-g phonegap

3.创建名为hello
$phonegap的应用程序create hello com.example.hello HelloWorld

4.转到hello目录
$cd hello

5.选择你的平台我向你展示的是ios,你也可以为Android构建平台

 $ phonegap build ios
[phonegap] detecting iOS SDK environment...
[phonegap] using the local environment
[phonegap] compiling iOS...
[phonegap] successfully compiled iOS app
6.添加要添加的插件
phonegap本地插件添加https://github.com/phonegap-build/BarcodeScanner.git

7.要远程编译应用程序,请在build命令前面加上其他远程命令:
$phonegap remote install ios
#……或者。。。

$phonegap remote run ios

以下是条形码扫描仪插件使用的示例:

<!DOCTYPE HTML>
<html>
<head>
  <title>Barcode Scanner DEMO</title>

<script type="text/javascript" src="plugins/plugin-loader.js"></script>   
<script type="text/javascript" charset="utf-8">

monaca.viewport({width : 320});

function scanBarcode() {
  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>
</head>

<hr> BarcodeReader DEMO <hr><br>
<input type="button" onClick ="scanBarcode()" value ="Scan" />
</body>
</html>

条形码扫描仪演示
monaca.viewport({width:320});
函数scanBarcode(){
window.plugins.barcodeScanner.scan(函数(结果){
警报(“我们得到了一个条形码\n”+
结果:“+Result.text+”\n+
格式:“+result.Format+”\n+
“已取消:“+结果.已取消”);
},函数(错误){
警报(“扫描失败:+错误”);
}
);
}
条形码阅读器演示

link github for barcode scanner phonegap plugin?希望您不是在谈论混合应用程序。我可以看出Monaca是用于混合应用的。我需要在手机中为我的网站(webapp)安装插件。您能否与我分享有关如何/在何处添加此插件的更多详细信息?