Login(){
alert(this.state.username);
this.props.navigator.push({
component: MainActivity
})
}
render() {
return<View style={styles.loginView}>
<Image style={styles.image} source={require('./Ionic.png')}/>
<Text style={styles.loginText}>Chat System</Text>
<TextInput style={styles.usernameText} placeholder="username" placeholderTextColor="black" onChangeText={(text) => this.setState({username: text})} />
<TextInput style={styles.passwordText} placeholder="password" placeholderTextColor="black" onChangeText={(text) => this.setState({password: text})} onSubmitEditing={this.Login} secureTextEntry/>
<TouchableWithoutFeedback onPress={this.Login}><View style={styles.loginButton}> <Text style={styles.loginButtonText}>Sign In</Text></View></TouchableWithoutFeedback>
<TouchableWithoutFeedback><View style={styles.signUpButton}><Text style={styles.signUpButtonText}>Sign Up</Text></View></TouchableWithoutFeedback>
<TouchableWithoutFeedback><View><Text style={styles.forgetPasswordText}>Forgot password?</Text></View></TouchableWithoutFeedback>
</View>
}
我需要在登录方法中获取用户名和密码输入的值,当点击登录或输入密码后按Enter键。
答案 0 :(得分:0)
我尝试了你的代码,显然是在那里有一个白色空间:
<TouchableWithoutFeedback onPress={this.Login}><View style={styles.loginButton}> <Text style={styles.loginButtonText}>Sign In</Text></View></TouchableWithoutFeedback>
导致错误。
答案 1 :(得分:0)
以下是一个工作示例:https://rnplay.org/apps/HVoVfw
您正在执行array(5) {
[0] =>
string(5) "file1"
[1] =>
string(5) "file2"
[2] =>
string(5) "file3"
[3] =>
string(5) "file4"
[4] =>
string(21) "file5 is the lastfile"
[5] =>
string(21) "file5 is the lastfile"
}
错误,正确的方法是:
Login