0
我想要的输出就像每当我按'编辑'它应该显示一些textInput字段。我该如何编写函数?以及如何将这些textInput值存储在变量中?是否有可能创建一个TextInput函数并通过按'编辑'来调用?谢谢按下按钮它应该显示TextInput字段
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;
这是有帮助的。以及如何在上面的代码中将textInput值分配给'systol'? – Prasanna
好吧,而不是systol只是使用>>>正文:JSON.stringify({entryDate:“2/27/2017 11:11 AM”,systol:this.state.textinput}) – Ataomega
非常感谢你.. – Prasanna