【发布时间】:2016-02-06 12:21:36
【问题描述】:
我一直在使用英特尔 XDK 构建小型应用程序。我尝试打开 Phonegap 条码扫描仪,但单击启动按钮时没有任何反应。我的目标是扫描二维码并打开包含结果数据的 inAppBrowser 链接。我同时安装了 Device (cordova-plugin-device) 和 Barcode Scanner (phonegap-plugin-barcodescanner) 插件,并具有相机和闪光灯的权限。
这是我的代码:
<script type="text/javascript">
document.addEventListener("deviceready", scanNow, false);
function scanNow() {
cordova.plugins.barcodeScanner.scan(
function (result) {
// alert("We got a barcode\n" +
// "Result: " + result.text + "\n" +
// "Format: " + result.format + "\n" +
// "Cancelled: " + result.cancelled);
window.open("http://www.example.com?qr=" + result.text, '_system', 'location=no');
},
function (error) {
alert("Error: " + error);
});}
</script>
这是启动按钮:
<a role='button' onclick="scanNow();">Scan</a>
编辑:我通过将此链接添加到我的索引页头的虚拟脚本来解决问题。
<script src="cordova.js"></script>
【问题讨论】:
标签: javascript cordova cordova-plugins intel-xdk