gpt4 book ai didi

javascript - 如何专注于第一个输入字段 - redux-form

转载 作者:搜寻专家 更新时间:2023-11-01 04:22:38 24 4
gpt4 key购买 nike

我正在尝试将任何形式的第一个输入字段设置为焦点。那么,实现这样的最佳实践是什么?我怎样才能检查字段的类型?是文本、数字、复选框还是其他?

是不是通过监听@redux-form Action ,然后派发一个焦点 Action ?

谁能提出解决方案?

最佳答案

我认为对于 redux-form (v6+) 目前的技术水平是提供 autoFocus <input /> 的属性您希望自动聚焦的内容。

例子:

<Field component={renderFirstInput} type="text" />

const renderFirstInput = field => {
return ( <input {...field.input} autoFocus /> )

}

Here is the Github issue link

您当然可以提供 autoFocus Prop 作为 field.input键。

关于javascript - 如何专注于第一个输入字段 - redux-form,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43016356/

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