美文网首页React Native开发
react-native-scan-code-cn

react-native-scan-code-cn

作者: 一朝瑾秋色 | 来源:发表于2020-12-01 11:34 被阅读0次

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

    Install

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

    Configuration

    • android
    1. run npx jetify
    2. In android/app/src/main/AndroidManifest.xml add:
    <uses-permission android:name="android.permission.CAMERA" />
    
    • ios
    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>
    

    相关文章

      网友评论

        本文标题:react-native-scan-code-cn

        本文链接:https://www.haomeiwen.com/subject/adtswktx.html