簡體   English   中英

React Native + Redux Form-在maxLength上轉到下一個字段

[英]React Native + Redux Form - on maxLength go to next field

您好,我想為Pin碼輸入4個,一切都很好,只是我想添加功能,所以當我們在Field1中編寫numer時,它將帶我們進入Field2等。這是我的代碼:

輸入組件:

 InputComponent = ({ input, meta, ...rest }) => (
    <Input {...rest} keyboardType="numeric" maxLength={1} value={input.value} onChangeText={input.onChange} />
  );

形成:

<Form style={styles.form}>
    <View style={styles.inputs}>
        <Field style={styles.input} name="pin1" component={this.InputComponent} placeholder="*" secureTextEntry />
        <Field style={styles.input} name="pin2" component={this.InputComponent} placeholder="*" secureTextEntry />
        <Field style={styles.input} name="pin3" component={this.InputComponent} placeholder="*" secureTextEntry />
        <Field style={styles.input} name="pin4" component={this.InputComponent} placeholder="*" secureTextEntry />
    </View>
</Form>

在這里您可以使用Ref來解決您的問題

這里

<FormInput
 ref='forminput'
 textInputRef='email'
 ...
 />

您應該能夠訪問類似於this.refs.forminput.refs.email.focus()的引用 對於每個信號輸入。

使用focus將根據ref聚焦特定的輸入,這里是帶redux形式REDUX_FORM的ref的示例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM