Ich möchte die Ausgabe wie, wann immer ich auf "Bearbeiten" drücken, sollte es einige TextInput Felder anzeigen. Wie kann ich Funktion dafür schreiben? und wie diese TextInput-Werte in Variable gespeichert werden? Ist das möglich, um eine Funktion zu erstellen, die TextInput fiellds hat und aufruft, indem du auf 'edit' drückst? dankeDrücken auf die Schaltfläche sollte TextInput Felder angezeigt werden
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TouchableOpacity,
TextInput,
TouchableHighlight,
Alert
} from 'react-native';
import Button from 'react-native-button'
import {Actions} from 'react-native-router-flux'
import Home from './Home'
export class Bp extends Component{
state={
responseBody:""
}
_onPressButtonPOST(){
return fetch("URL", {
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({entryDate:"2/27/2017 11:11 AM",systol:"900"})
})
.then((responseData) => {
this.setState({
responseBody: JSON.stringify({entryDate:"2/27/2017 11:11 AM",systol:"900"})
})
})
.done();
}
render(){
return(
<View>
<TouchableOpacity>
<Text> Edit </Text>
</TouchableOpacity>
<TouchableOpacity onPress={this._onPressButtonPOST.bind(this)} >
<Text> Show </Text>
{this._renderBody(this.state.responseBody)}
</TouchableOpacity>
</View>
);
}
_renderBody(responseBody){
if(responseBody){
var parsedBody=JSON.parse(responseBody);
return (<View>
<Text>{parsedBody.entryDate}</Text>
<Text>systolic:{parsedBody.systolic}</Text>
<Text>diastolic:{parsedBody.diastolic}</Text>
<Text>pulseRate:{parsedBody.pulseRate}</Text>
</View>);
}
}
}
module.exports = Bp;
das ist hilfreich. und wie kann ich TextInput Wert zu "Systol" im obigen Code zuweisen? – Prasanna
gut, statt systol einfach verwenden >>> body: JSON.stringify ({entryDate: "27.02.2017 11:11 AM", systol: this.state.textinput}) – Ataomega
vielen Dank .. – Prasanna