【发布时间】:2017-06-04 14:44:55
【问题描述】:
您好,我正在尝试关注下一个输入字段(从父级扩展),同时点击下一个(在 android 键盘中)android 键盘关闭并且不关注下一个字段。
我尝试了一些代码,例如 onSubmitEditing= this.refs.passwordFeald.focus() 它不起作用,如果有人解释它也更好,我对命名组件有点困惑
以下是我当前的代码
export default class InputBox extends Component {
focusNextField = (nextField) => { this.refs[nextField].focus(); };
render(){
return(
<TextInput
style = {style.input}
underlineColorAndroid='rgba(255,255,255,0.7)'
placeholderTextColor = "rgba(255,255,255,0.6)"
placeholder = {this.props.placeholder}
secureTextEntry={this.props.typePassword}
returnKeyType = {this.props.returnKeyType}
ref = {this.props.inputRef}
focusNextField = {() => this.focusNextField(this.props.onSubmitEditing)}
/>
)
}
}
export default class Login extends Component {
render(){
return(
<View style={[styles.container, commonStyle.background]}>
<View style={[headerContStyle.topContainer]}>
<MainHeading/>
</View>
<View style={[formStyle.container]}>
<InputBox
placeholder = "Email or username"
returnKeyType = "next"
inputRef = {el => this.usenameFeald = el}
onSubmitEditing= 'passwordFeald'
/>
<InputBox
placeholder = "Password"
secureTextEntery = {"true"}
returnKeyType = "go"
inputRef = {el => this.passwordFeald = el}
typePassword = {true}
/>
<CommonButton
title = "Login"
/>
<CommonButton
title = "Sign Up"
/>
<ForgotPassword />
</View>
</View>
)
}
}
【问题讨论】:
标签: reactjs react-native ecmascript-6