今天公司需求在tooltip显示时自动获取焦点,直接用ref.current.focus({ cursor: 'start'})不会自动聚焦
后来才发现需要做异步处理,在下一个生命周期中实现聚焦具体代码为
const ref = useRef<InputRef>(null); //搜索vin
<Input ref={ref} placeholder="搜索" />
time = setTimeout(function () {
ref.current?.focus({
cursor: 'start',
});
}, 10);
973

被折叠的 条评论
为什么被折叠?



