反应原生onKeyPress不工作?
我刚刚放置TextInput KeyboardType ={"numeric"}
只是试图找到天气用户输入' - '如果意味着我必须在OnChange首先event.preventDefault()
.Later尝试在onKeyPress但onKeyPress不trigerring,我只是试图做到这一点,但它让我键入显示警告综合事件性能问题。反应原生onKeyPress不工作?
伙计们帮助我。
你用Android手机的测试,而onKeyPress
方法是iOS
,检查documentation为同一
可以使用onChangeText
文本的变化。
例子:
<TextInput
onChangeText={(text) => this.onFirstNameText(text)}
returnKeyType={'next'}
underlineColorAndroid='transparent'
style={styles.inputColLeft}
/>
确定那么如何访问event.preventDefault() – saiRam89
尚未使用,但你需要吗?,验证数字只有你可以检查:https://stackoverflow.com/questions/32946793/react -native-的TextInput - 即只-接受数字字符 –
使用onChangeText这样的:
<TextInput onChangeText = {(text) => this.getPhone(text)} keyboardType="numeric" autoCapitalize="none" autoCorrect={false} onSubmitEditing={() => this.addressInput.focus()} style={styles.input} placeholder="phone" placeholderTextColor="rgba(255,255,255,0.6)" underlineColorAndroid="rgba(0,0,0,0.0)" returnKeyType="next"/>
getPhone = (text) => {
this.setState({phone: text})
//use your logic here
}
在哪个平台正在测试?您是否正在使用Android模拟器测试 –
? –
Andriod没有在移动奥利 – saiRam89