如何使用ReactJS组件将自动对焦 HTML属性包含到输入中?
我尝试使用包含自动聚焦输入的React元素
<input className='EI-input' autoFocus='true' tabIndex='0'
name='username' type='text'
ref='inputUser' autoComplete='on'
placeholder='email' />
Run Code Online (Sandbox Code Playgroud)
但是当渲染到静态标记时,我没有看到在浏览器中呈现自动聚焦属性(使用Chrome和FireFox中的devTools进行检查)
const jsx = React.renderToStaticMarkup(<InputWithAutoFocus />);
console.log(jsx); // I don't see the autofocus attribute in the input
Run Code Online (Sandbox Code Playgroud)
我也尝试过autoFocus和autoFocus ='on'和自动对焦.这些似乎都不起作用.
根据ReactJS文档,autoFocus应该可以工作.
| 归档时间: |
|
| 查看次数: |
1488 次 |
| 最近记录: |