cordova制作ios扫一扫

第一步
添加依赖:

cordova plugin add cordova-plugin-camera  --添加调用相机依赖
cordova plugin add phonegap-plugin-barcodescanner  --添加调用扫一扫依赖

第二步
添加配置:(在config.xml)

<plugin name="phonegap-plugin-barcodescanner" />
<preference name="android-build-tool" value="gradle" />

第三步
调用:

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) {
          console.log("Scanning failed: " + error);
        },
        {
          preferFrontCamera: false, // 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
        }
      );
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值