gpt4 book ai didi

css - 如何从一个文本字段更改为另一个文本字段

转载 作者:行者123 更新时间:2023-11-28 19:11:14 25 4
gpt4 key购买 nike

我有 4 个文本字段,用于输入发送到手机的 4 位代码。如果写入数字并且不带数字以外的任何内容,我如何自动更改到下一个字段我附上一张图片和我的代码库 enter image description here

// flow
import React, { useRef } from 'react';
import { signup } from '../../assets/images';
import FormDiv from '../shared/Sign-in-div';
import ImageDiv from '../shared/Image-div';
import { Nunito32, Nunito20 } from '../shared/nunito/nunito';
import ImageContainer from '../shared/image-container';
import OtpField from '../shared/otp-field';
import PinkButton from '../shared/button-color-pink';

let [fieldOne, fieldTwo, fieldThree, fieldFour] = useRef(null);

const onChange = field => {
field.focus();
};

const SignUpVerification = () => (
<div style={{ display: 'flex' }}>
<FormDiv style={{ textAlign: 'center' }}>
<Nunito32
style={{
display: 'inline-block',
textAlign: 'center',
marginRight: 236,
marginLeft: 200,
}}
>
Verify your mobile number by entering the code we sent you
</Nunito32>
<div style={{ flexDirection: 'row' }}>
<OtpField
ref={input => {
fieldOne = input;
}}
style={{ marginRight: 10.5 }}
onChange={() => onChange(fieldTwo)}
/>
<OtpField
ref={input => {
fieldTwo = input;
}}
onChange={() => onChange(fieldThree)}
style={{ marginRight: 10.5 }}
/>
<OtpField
ref={input => {
fieldThree = input;
}}
onChange={() => onChange(fieldFour)}
style={{ marginRight: 10.5 }}
/>
<OtpField
ref={input => {
fieldFour = input;
}}
style={{ marginRight: 10.5 }}
/>
</div>

<PinkButton style={{ marginTop: 75 }}>Continue</PinkButton>
<Nunito20>Send again</Nunito20>
</FormDiv>
<ImageContainer>
<ImageDiv bg={signup} src={signup} alt="logo" />
</ImageContainer>
</div>
);

export default SignUpVerification;

它现在给我 2 个错误,fieldOne 已创建但未使用,并且 ×错误:无效 Hook 调用。钩子(Hook)只能在函数组件的主体内部调用。这可能由于以下原因之一而发生:

最佳答案

当你改变状态时重新渲染怎么样?

关于css - 如何从一个文本字段更改为另一个文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59245038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com