![](/img/trans.png)
[英]installed barcode scanner plugin with capacitor, pwa complain cordova not available
[英]barcode scanner along with cordova camera preview
如何將 phonegap 條形碼掃描儀插件與 cordova-plugin-camera-preview 一起使用,以便當我在我的 angular 應用程序中單擊掃描按鈕時,相機會在我的應用程序內預覽並掃描條形碼並給出結果
你讓自己變得復雜
條形碼掃描儀插件是
上面提到的條形碼掃描儀已經可以訪問相機,您不必使用另一個插件,例如您提到的cordova相機預覽插件
例子:
//plugin options
var options= {
preferFrontCamera : true, // iOS and Android
showFlipCameraButton : true, // iOS and Android
showTorchButton : true, // iOS and Android
torchOn: true, // Android, launch with the torch switched on (if available)
saveHistory: true, // Android, save scan history (default false)
prompt : "Place a barcode inside the scan area", // Android
resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
disableAnimations : true, // iOS
disableSuccessBeep: false // iOS and Android
}
//success callback
function onSuccess(result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
}
//error callback
function onError(error) {
alert("Scanning failed: " + error);
}
cordova.plugins.barcodeScanner.scan(onSuccess, onError, options);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.