input自动聚焦问题 在react中可以使用refs解决这个问题,首先看一下refs的使用场景: (1)处理焦点.文本选择或媒体控制. (2)触发强制动画. (3)集成第三方 DOM 库. 使用refs解决input聚焦的问题有两种应用场景: 1.组件内部: 在input内部定义ref,当给 HTML 元素添加 ref 属性时,ref 回调接收了底层的 DOM 元素作为参数.例如,下面的代码使用 ref 回调来存储 DOM 节点的引用. class CustomTextInput extend
React based applications often use controlled inputs, meaning the input event leads to the application code setting the value of the very input we’re typing into. Since this moves the input setting behavior into the application code, we should have a