React Native开发

react-native-scan-code-cn

2020-12-01  本文已影响0人  一朝瑾秋色

最近要用到扫描,一开始用的react-native-camera,但是没有后置摄像头光源捕捉,不能做到和微信支付宝一样的手电筒逻辑,那就自己写一个

Install

yarn add react-native-scan-code-cn
或者
npm install react-native-scan-code-cn --save

Configuration

  1. run npx jetify
  2. In android/app/src/main/AndroidManifest.xml add:
<uses-permission android:name="android.permission.CAMERA" />
  1. run npx pod-install

Usage

Make sure permissions are turned on before using

import { RNScanCode } from 'react-native-scan-code-cn'

<RNScanCode
    onBarCodeRead={res => {
        console.log('扫码结果 = ', res)
    }}
    onLightBright={light => {
        console.log('当前的光源= ', light)
    }}
>
    
    {/* 其他UI */}
</RNScanCode>
上一篇下一篇

猜你喜欢

热点阅读