简体   繁体   English

在文本输入中将文本作为参数传递本机反应

[英]Passing text as param in textinput react native

           <TextInput
             ref={(ref) => (this.qty = ref)}
             style={DefaultStyles.SeedFundSummaryTextInput}
              keyboardType='numeric'
              disabled={this.props.navigation.state.params.edit == false}
              theme={{ colors: { text: 'rgba(0, 0, 0, .5)' } }}
              // value={item.qty <= item.allowed_bags&&this.state.enable_pc_limit_check==1? 
                item.qty.toString() : ''}
              value={ item.qty}
              onBlur={ (text) => this.handleOnBlur(text) }
              maxLength={5}
              onChangeText={(text) => { /*item.qty = text;*/ this.handleBags(text, item)}} />

                async handleOnBlur(text){
                console.log(text,'onBlur')
                }

Here is my code, i want to get the text in Onblur function as i get in onchangetext.这是我的代码,我想在 onchangetext 中获取 Onblur function 中的文本。 What should i do?我应该怎么办?

The event is passed as param to onBlur callback, which you can get text from via nativeEvent prop:该事件作为参数传递给onBlur回调,您可以通过nativeEvent从中获取文本:

<TextInput onBlur={e => console.log('text', e.nativeEvent.text)}/>

You can find more info here你可以在这里找到更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM