我正在使用React Native构建一个Android应用程序.
如何强制a TextInput"unFocus",这意味着光标在文本字段内闪烁.有对功能isFocused()和onFocus(),但实际上,我怎么得到的文本字段放弃焦点.一旦我点击进入,你会认为它会自动完成,但事实并非如此.
import React, {Component} from 'react';
import { AppRegistry, Text, View, StyleSheet, TextInput, TouchableOpacity}
from 'react-native';
var SHA256 = require("crypto-js/sha256");
export default class LoginForm extends Component{
constructor(props){
super(props);
this.state = {
email: '',
password:''
};
}
tryLogin = () => {
if(this.state.email=="email123" && this.state.password == "password"){
console.log("password verified");
this.props.navigator.replace({
title: 'Dashboard'
});
}
console.log(this.state.email);
console.log(this.state.password);
console.log("Hash" + SHA256(this.state.password));
}
render(){
return(
<View style={styles.container}>
<TextInput
style={styles.input}
placeholder="Email address"
placeholderTextColor="white"
onChangeText={(email) => this.setState({email})}>
</TextInput> …Run Code Online (Sandbox Code Playgroud)