Ich verwende reagieren native, um in Android zu entwickeln. Und ich möchte eine Datei oder ein Foto auf Server hochladen .Und ich reagieren-native-Datei-Uploader, und ich bekam Fehler:wie man Foto in reagieren native android
[undefined ist kein Objekt (Bewertung ‚_reactNative.NativeModules.FileUploader.upload ')], Cannot read property 'upload' of undefined2
bitte helfen, Danke! unten ist mein Code:
import React from 'react';
import {
View,
Text,
Image,
StyleSheet,
TouchableOpacity,
Platform,
DeviceEventEmitter
} from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome'
import FileUploader from 'react-native-file-uploader'
const settings = {
/* uri,
uploadUrl,
method, // default to 'POST'
fileName, // default to 'yyyyMMddhhmmss.xxx'
fieldName, // default to 'file'
contentType, // default to 'application/octet-stream'
data: {
// extra fields to send in the multipart payload
}*/
};
export default class NewDishView extends React.Component{
constructor(props){
super(props)
this.state={
avatarSource:'./src/images/support.png'
}
}
goBack(){
this.props.navigator.pop();
}
render(){
return (
<View>
<View style={styles.header}>
<TouchableOpacity onPress={()=>this.goBack()} style={styles.back}>
<Icon style={styles.backIcon} name="chevron-left" />
</TouchableOpacity>
<View style={{flex:1}}>
<Text style={styles.title}>Create new dish</Text>
</View>
</View>
<TouchableOpacity onPress={
FileUploader.upload(settings, (err, res) => {
// handle result
}, (sent, expectedToSend) => {
// handle progress
})
}>
<Text>upload</Text>
</TouchableOpacity>
</View>
)
}
}
const styles = StyleSheet.create({
header:{
flexDirection:'row',
},
back:{
paddingLeft:10,
paddingTop:5,
width:25,
},
backIcon:{
color:'#000',
fontSize:20,
},
title:{
fontSize:20,
textAlign:'center',
},
})