我試過barcodescanner.js samples,這是我需要Qrcode閱讀器的phonegap項目,提供的示例項目在xcode中工作正常。 iam試圖開發一個獨立的項目時出現問題。phonegap項目中的barcodescanner插件問題
- 我config.xml文件有:
<plugin name="com.cordova.barcodeScanner" value="CDVBarcodeScanner" />
- IAM使用:PhoneGap的2.7.0
- 我已經包括
barcodescanner.js
和它的標籤正確。
我的代碼:
function onDeviceReady()
{
// do your thing!
navigator.notification.alert("PhoneGap is working");
scanButton = document.getElementById("scan-button");
resultSpan = document.getElementById("scan-result");
scanButton.addEventListener("click", clickScan, false);
createButton.addEventListener("click", clickCreate, false);
}
function clickScan() {
alert("clickScan");
window.plugins.barcodeScanner.scan(scannerSuccess, scannerFailure);
}
function scannerSuccess(result) {
console.log("scannerSuccess: result: " + result)
resultSpan.innerText = "success: " + JSON.stringify(result)
}
function scannerFailure(message) {
console.log("scannerFailure: message: " + message)
resultSpan.innerText = "failure: " + JSON.stringify(message)
}
它是確定,直到警報; 「clickscan」,
之後沒有任何反應(什麼阻止我的window.plugins.barcodeScanner.scan(scannerSuccess, scannerFailure);
工作)。
這是我的項目看起來像 - >
蔭這種掙扎了兩天,我在SO檢查幾乎所有問題上「barcodescanner」標籤,did'nt解決了我的問題,需要你幫助..謝謝。
你有沒有加入CDVBarcodeScanner.mm和斑馬線,所有功能於one.cpp/.H到CordovaLib /插件? 'alert(typeof window.plugins.barcodeScanner)'會在'clickScan'函數中顯示什麼? – pawel
是啊...它都在那裏..警報(typeof window.plugins.barcodeScanner);沒有顯示任何東西 –
@pawel:還有其他的東西需要配置嗎? (也看@我的項目樹)。 –