这是我的我尝试过但无法解决这个简单的问题
export default class LoginScene extends Component {
constructor(props) {
super(props);
this.state = {
userid: '',
password: '',
};
}
componentWillMount() {
// this.fetchData();
}
veryfyLogin() {
fetch(LOGIN_URL)
.then((response) => {
if (response.status === 200) {
var navigator = this.props.navigator;
navigator.push({
id: 'dashboard',
title: 'DashBoardScene',
index: 1
});
}
Alert.alert(response.status);
})
.done();
}
render() {
onButtonPress = () => {
Alert.alert("userid:::"+this.state.userid+"Password:::"+this.state.password);
this.veryfyLogin();
};
return (
<View >
<Text> User Name: </Text>
<TextInput
style={{ height: 40 }}
ref= {(el) => { this.userid = el; }}
placeholder="enter your email address"
onChangeText={(userid) => this.setState({ userid })}
value={this.state.userid}
/>
<Text> Password: </Text>
<TextInput
ref= {(el) => { this.password = el; }}
style={{ height: 40 }} password={true}
placeholder="password"
onChangeText={(password) => this.setState({ password })}
value={this.state.password}
/>
<Button
title="Login"
color="#841584"
onPress={onButtonPress}
accessibilityLabel="Learn more about purple"
/>
</View>
)
}
}
LoginScene.propTypes = {
title: PropTypes.string.isRequired,
// onForward: PropTypes.func.isRequired,
// onBack: PropTypes.func.isRequired,
};
AppRegistry.registerComponent('LoginScene', () => LoginScene);