加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

react-native – React native onKeyPress无效?

发布时间:2020-12-15 09:32:37 所属栏目:百科 来源:网络整理
导读:我刚刚放置TextInput KeyboardType = {“numeric”}只是试图找到天气用户输入’ – ‘如果我必须首先在OnChange中的event.preventDefault().后来在onKeyPress尝试但是onKeyPress不是trigerring,我刚试过要做到这一点,但它允许我键入显示警告综合事件性能问题
我刚刚放置TextInput KeyboardType = {“numeric”}只是试图找到天气用户输入’ – ‘如果我必须首先在OnChange中的event.preventDefault().后来在onKeyPress尝试但是onKeyPress不是trigerring,我刚试过要做到这一点,但它允许我键入显示警告综合事件性能问题.

伙计们帮帮我

解决方法

你正在用 android mobile测试whereasonKeyPress方法适用于iOS,检查 documentation是否相同

您可以使用onChangeText进行文本更改.

例:

<TextInput
    onChangeText={(text) => this.onFirstNameText(text)}
    returnKeyType={'next'}
    underlineColorAndroid='transparent'
    style={styles.inputColLeft}
/>

编辑2018

根据this commit,Android设备现在也支持onKeyPress.

来自doc:

Note: on Android only the inputs from soft keyboard are handled,not the hardware keyboard inputs.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读