[我正在尝试使用包装在antd
中的无状态功能组件中的<Table>, <Form>
<Input>
和Form.create()()
来创建自定义可编辑表。
此刻,每当我在<Input>
中输入单个字符或移动鼠标时,该字段就会失去焦点。
我试图通过使用以下方法来关注<Input>
:
const inputEl = useRef(null);
...
<Input
ref={inputEl}
onChange={()=> {inputEl.current.focus()}}
/>
但是那不起作用,因为您无法在focus()
上使用<Input>
。
有什么方法可以使它正常工作?
您假设Input
引用具有focus
的input
功能,但实际上,由于它是input
的实现,因此它在input
对象中拥有正确的引用: