- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试渲染 <input>
字段与 autofocus
:
<input type="text" autoComplete="off" autoFocus={true} className="form-control" />
<input type="text" autocomplete="off" class="form-control">
autofocus
要渲染的属性?
最佳答案
这是意料之中的,实际上。 React 会手动调用 focus()
在相关元素上,但不会添加属性本身。
这是来自 ticket response 的 Dan Abramov 的引述。大约 2 年前:
This is intentional because it works very differently in different browsers. So instead of actually setting a DOM attribute, we polyfill its behavior in JavaScript.
Chrome respects dynamically added elements with autoFocus if there hasn’t been one before. Even creating an input with autoFocus, adding it to the document, and removing it in the next tick is enough to disable autofocusing of any elements added in the future in Chrome.
Firefox just doesn’t care about any dynamically added elements with autoFocus at all.
And Safari always respects them.
autofocus="true"
强制该属性。而不是
autoFocus={true}
但它实际上可能无法以可靠的方式工作。毕竟,React 团队对此进行 polyfill 是有原因的。
autoFocus
, 如果你必须有 native 属性,你可以使用
autofocus="true"
,但要知道,您将受制于让浏览器决定何时以及如何聚焦所述元素。
关于reactjs - React autoFocus 属性未呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60216787/
使用 Django 1.9 和 python 3.5,我想“设置焦点”在我的模型表单中验证失败的第一个字段。 这是如何实现的? 谢谢。 最佳答案 我相信以下内容对您有用。 (未经测试) 在表单的 __
我在一篇文章的底部设计了一个脚注来注释后续状态; add a footnote 当“add a footnote”链接被点击后隐藏时提示我设置autofocus textarea的“f
我有一个隐藏的 div。单击链接时,div 应与 input 字段和下拉列表 select 切换。如何在 div 向下滑动时立即使此输入字段自动对焦? 这是我的隐藏 DIV 的 HTML:
我正在尝试渲染 字段与 autofocus : 但它被渲染为: 并且输入不聚焦。 这是为什么? 我如何获得 autofocus要渲染的属性? 最佳答案 这是意料之中的,实际上。 React 会手动
我想知道是否可以在 iPhone 应用程序内接收有关自动对焦的通知? 即,是否存在一种在自动对焦开始、结束、成功或失败时收到通知的方法...? 如果是,该通知名称是什么? 最佳答案 我找到了适合我的案
我在 d3.js 中编写代码,有时使用 input 元素来收集用户的输入,而无需使用 form。这很好用。 但我注意到我无法在动态页面上始终如一地应用 autofocus 属性;它仅在第一次应用时有效
我似乎记得以前版本的 HTML(在 HTML5 之前)中的大多数(也许是全部)属性都要求属性具有值,例如 readonly="readonly"。 HTML5 和 autofocus 属性是否如此?
我有一个受控输入,它最初显示一个值。我已将该输入设置为 autoFocus,但当我希望它出现在末尾时,光标出现在输入的开头。我知道这可能是因为 autoFocus 是在值之前添加的,但我不是 100%
我在 Modal 中有一个 TextInput,带有 autoFocus={true}。一旦 Modal 打开,TextInput 就会自动聚焦,但键盘不会自动打开。令人惊讶的是,这是随机发生的。有时
我使用 Ionic 2 构建了一个 Angular Reactive Form。 当我触摸页面底部的输入时,页面会滚动,因此输入位于键盘上方。预期的行为,所以确定。但是头球也被推了,这是错误的。 所以
我正在尝试向表单添加自动对焦。我让它在 Chrome 中工作,但无法使用以下代码在 Firefox 中工作。我认为原因可能是它只需要 autofocus 而不是 autofocus="autofocu
使用 sweetalert2@8 使用以下代码对搜索框使用甜蜜警报。自动对焦适用于 Chrome,但不适用于 Safari 和 Firefox。我们该如何解决这个问题? swal.fire({
我编写的指令在 firefox(36.00 版)中不起作用。 这应该与 html 5 中的 atuofocus 属性相同。 代码如下: app.directive('autoFocus', funct
在AndEngine AugmentedReality中,我发现有一个“mCamera.autoFocus(myAutoFocusCallback);” CameraPreviewSurfaceVie
我有一个允许用户拍照的相机应用程序。在我的主屏幕上,我在 SurfaceView 上渲染了一个相机。当用户拍照时,我调用 camera.autoFocus,并在 AutoFocusCallback 回
有人知道如何在页面加载时自动聚焦在 CKEDITOR 文本区域吗? 目前,用户必须先点击文本区域才能开始输入。像 Google 一样,我希望页面加载后用户可以立即开始输入而无需单击文本区域。 这是启动
在下面的示例中,我只得到一个警告框。我读到焦点放在执行 JavaScript 代码之前。有没有办法让它继续工作? document.getElementById('i').addEventList
我正在使用 android compose jetpack 版本“0.1.0-dev14”。根据应用程序要求,一旦屏幕可见,我想自动聚焦 TextField。另一种情况是,我想将同一屏幕中的下一个 T
我想创建一个带有 6 个 TextInput 的 OTP 输入屏幕。当我键入前一个 TextInput 的值时,我希望 TextInput 自动聚焦到下一个。 我遵循了 the following q
我的输入具有自动完成功能: .autocomplete({ source: "jsonR.php", minLength
我是一名优秀的程序员,十分优秀!