1
我試圖創建一個默認的Phonegap條碼掃描器槽插件基本安裝,但它不能正常工作。我不知道發生了什麼事。這裏是我的代碼:Phonegap條碼掃描器:無法運行
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
console.log('-');
console.log(cordova);
console.log('-');
console.log(cordova.plugins.barcodeScanner);
console.log('-');
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);
}
);
}
};
它基本上是默認的Phonegap插件面板。問題是它不承認cordova.plugin.barcodeScanner
。我通過Phonegap Windows工具創建了該項目,並在該文件夾中運行了cordova plugin add cordova-plugin-statusbar
命令。請幫助我,我看不到這個工作的任何代碼示例。謝謝。
什麼也沒有發生,我東西,這可能是我的項目的一些missconfiguration, http://www.filedropper.com/homemarket <我上傳了我的項目,我使用phonegap工具創建了它,並按照github工具的說明安裝它 –