ReactNative 常用组件

react-native-swiper

github

ReactNative 常用组件_第1张图片
example

react-native-parallax-view

github

example

react native drawer

github

example

react-native-image-picker

github

ReactNative 常用组件_第2张图片
Paste_Image.png

安装:

npm install react-native-image-picker@latest --save

ios注意:

ReactNative 常用组件_第3张图片
添加
ReactNative 常用组件_第4张图片
不要选错项目!

使用:

import {Platform} from 'react-native';
import ImagePicker from 'react-native-image-picker';

selectImage () {
    // 官网例子
    let options = {
        title: 'Select Avatar', 
        customButtons: {
             'Choose Photo from Facebook': 'fb',
        },
        storageOptions: {
            skipBackup: true,
            path: 'images'
        }
    };
    ImagePicker.showImagePicker(options, (response) => {
        console.log('Response = ', response);
        if (response.didCancel) {
            console.log('User cancelled image picker');
        }
        else if (response.error) {
            console.log('ImagePicker Error: ', response.error);
        } 
       else if (response.customButton) { 
           console.log('User tapped custom button: ',  response.customButton);
        }
        else {
            // You can display the image using either data...
            const source = {uri: 'data:image/jpeg;base64,' + response.data, isStatic: true}; 
           // or a reference to the platform specific asset location
            if (Platform.OS === 'ios') { 
               const source = {uri: response.uri.replace('file://', ''), isStatic: true};
            } else { 
               const source = {uri: response.uri, isStatic: true};
            }
            this.setState({
                avatarSource: source
            });
        } 
   });}



    

你可能感兴趣的:(ReactNative 常用组件)