cordova plugin add phonegap-plugin-barcodescanner
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);
      },
      {
          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   横屏(landscape)竖屏(portrait)
          disableAnimations : true, // iOS 
          disableSuccessBeep: false // iOS and Android
      }
   );

点赞(0) 打赏

Comment list 共有 0 条评论

暂无评论
立即
投稿
发表
评论
返回
顶部