0
Phonegap에 대한 새로운 기능입니다. 바코드를 스캔해야하는 응용 프로그램에서 다음과 같은 .js 파일을 사용하여 scanning.this js 파일을 HTML 페이지에서 호출했습니다. iOS에서는 잘 작동하지만 안드로이드에서는 바코드를 스캔하지 않는 이상한 시간에만 스캔합니다. 어느 누구도이 호를 고칠 수 있습니까?phonegap 바코드 스캐너가 안드로이드에서 처음으로 작동하지 않습니다
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
document.getElementById('scan').addEventListener('click', this.scan, false);
},
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
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;');
},
scan: function() {
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
scanner.scan(function(result) {
window.location.href = "scan?id=" + result.text;
}, function(error) {
alert("scan function error");
console.log("Scanning failed: ", error);
});
}
};