React-Native(2)--第三方库

引入第三方RN插件##

以react-native-camera(摄像头二维码相关应用)为例

安装插件,关联插件,简单方便###

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

react-native link

react-native-camera因为这个使用到摄像头所以在ios10+需要设置info

Privacy - Camera Usage Description

使用例子

/**
 * Created by luxiaolong on 16/10/25.
 */
'use strict';

import React from 'react';

import {
    StyleSheet,
    View,
    Text,
    TouchableOpacity,
    VibrationIOS,
    } from 'react-native';

import Camera from 'react-native-camera';

var QRCodeScreen = React.createClass({


    render: function() {


        return (
            
                
                    
                
                {cancelButton}
            
        );
    },
    _onBarCodeRead: function(result) {
        var $this = this;

        if (this.barCodeFlag) {
            this.barCodeFlag = false;

            setTimeout(function() {
                VibrationIOS.vibrate();
                console.log(result.data);
            }, 1000);
        }
    }

});

module.exports = QRCodeScreen;

你可能感兴趣的:(React-Native(2)--第三方库)