/** * Sample React Native App * https://github.com/facebook/react-native * * @format * @flow */ import React, {Component} from 'react'; import {Platform, StyleSheet, Text, View ,Image} from 'react-native'; import ImagePicker from 'react-native-image-crop-picker'; const instructions = Platform.select({ ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu Text for dev menu', }); export default class App extends Component{ constructor(props){ super(props) this.state={ list:[{}] } } componentWillMount(){ } render() { const {list} = this.state return ( { ImagePicker.openPicker({ width: 300, height: 400, cropping: true, cropperChooseText:'确认', cropperCancelText:"取消" }).then(image => { list.push(image) this.setState({ list }) console.log(image); }); }}> 点击 { ImagePicker.openPicker({ multiple: true, cropping:true, cropperChooseText:'确认', cropperCancelText:"取消" }).then(images => { list.push(images) this.setState({ list }) console.log(images); }); }}> 点击 { ImagePicker.openCamera({ width: 300, height: 400, cropping: true, cropperChooseText:'确认', cropperCancelText:"取消" }).then(image => { list.push(image) this.setState({ list }) console.log(image); }); }}> 点击 { list.map((item,index)=>{ console.log(item.path) let source = { uri: item.path }; return ( ) }) } ); } } const styles = StyleSheet.create({ margin:{ marginBottom:20 }, container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, });