reactjs - ReactJS react-step-wizard 在动画后关注输入
问题描述
我使用这个包https://www.npmjs.com/package/react-step-wizard在表单之间制作动画。每个表单都是独立的组件。
完成幻灯片动画后如何将焦点设置为活动形式的输入?
解决方案
您是否尝试过componentdidmount?
像这样的东西?
class App extends React.Component{
componentDidMount(){
this.nameInput.focus();
}
render() {
return(
<div>
<input
defaultValue="Won't focus"
/>
<input
ref={(input) => { this.nameInput = input; }}
defaultValue="will focus"
/>
</div>
);
}
}
推荐阅读
- python - 如何使用 Python 组合 JSON 数据的相同键的所有值
- python - WTFforms:如何避免 NumberRange 验证器中的大整数溢出错误?
- javascript - 如何使用 Immutability-helper 进行条件更新
- azure - 如何在 Azure 突触中按需定义日期格式
- apache - 如何在 apache2 网络服务器中要求特定路径的 REFERER?
- aws-lambda - Amazon Lex 插槽不会在其中保存价值。返回空
- javascript - 输出$ref时'value'和'_value'之间的Vue区别
- c# - List.Add 函数添加对对象的引用或将其值添加到列表中
- python - 比较两个数据框列并分配零和一
- sql - SQL - 如何查找所有电子邮件地址?