html - 在输入元素上使用自动对焦时出错(Reactjs)
问题描述
我有以下元素
<textarea className='title' autofocus="autoFocus"
onChange={(e)=>changeBill(e, 'title')}
value={bill?.title}
placeholder="Bill Title">
</textarea>
当我打开浏览器时,它会给出以下警告:
警告:无效的 DOM 属性
autofocus
。你的意思是autoFocus
?
它仍在工作,但警告非常烦人。我试过“自动对焦”和“自动对焦”都不能阻止警告。
解决方案
警告不是关于属性的值,而是属性名称本身。它应该是:
<textarea className='title' autoFocus={true}
onChange={(e)=>changeBill(e, 'title')}
value={bill?.title}
placeholder="Bill Title">
</textarea>
该物业也接受true
或false
。在您的示例中,非空字符串被解释为true
.
推荐阅读
- aws-lambda - 错误 [a bytes-like object is required, not 'str' ] in importing CSV to DynamoDB using python
- java - NoSuchElementException 使用扫描仪
- amazon-cloudwatch - AWS Glue - Cloudwatch 事件 - 如何获取作业事件触发器的自定义参数
- angular - 如何在 ionic 4 中使用过滤器?
- wso2is - WSO2 ISKM 5.7.0 - mysql 辅助用户存储 - 自动重新连接属性不起作用
- python - 如何使用另一个表在 python SQL 中创建一个表?
- c# - 有没有办法使用 Artifacts 提要使用 Squirrel 进行更新?
- ssl - 结合端口 587 和 SSL 是否安全?
- python - 在 Python 中转换嵌套的字典列表
- c# - 实体框架 Linq 连接方法语法