React Native 二维码扫描 react-native-camera的使用

      最近写项目用到了二维码扫描,就去找了下,发现有个第三方的react-native-camera,支持android 和ios,功能还挺强大的,有兴趣的朋友可以去看下https://github.com/lwansbrough/react-native-camera。以下是我的自己写的一个仿微信样式写的二维码扫描。

    首先导入react-native-camera

  1. npm install react-native-camera@https://github.com/lwansbrough/react-native-camera.git --save
  2. react-native link react-native-camera

    import React from 'react';
    import {
        StyleSheet,
        TouchableOpacity,
        View,
        Text,
        InteractionManager,
        Animated,
        Easing,
        Platform,
        Image
    } from 'react-native';
    import Camera from 'react-native-camera';
    var Dimensions = require('Dimensions');
    var {width, height} = Dimensions.get('window');
    
    export default class CodeReading extends React.Component {
        constructor(props) {
            super(props);
            this.camera = null;
            this.state = {
                show:true,
                anim: new Animated.Value(0),
                camera: {
                    aspect: Camera.constants.Aspect.fill,
                },
            };
        }
        componentDidMount(){
            InteractionManager.runAfterInteractions(()=>{
               this.startAnimation()
            });
        }
        startAnimation(){
            if(this.state.show
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值