【问题标题】:label "for" is not being displayed in the frontend标签“for”未显示在前端
【发布时间】:2016-10-05 16:58:00
【问题描述】:

我正在尝试在标签中设置 for,但是反应引擎忽略了它。 (我可能做错了)

谁能帮我正确的语法在 JSX 标签中使用“for”。

这是我的代码 sn-p

<form role="form">
    <div className="checkbox checkbox-primary">
          <input type="checkbox" className="styled" id="checkbox1" name="foambox" ref="foambox" />
          <label for="checkbox1"><span style={{margin:10,cursor:'default'}}>For this delivery, would you like us to   take back the foam box </label>
    </div>
 </form>

指定它的正确方法是什么?

【问题讨论】:

标签: forms reactjs


【解决方案1】:

htmlFor 是您在React Documentation 中看到的正确语法

所有属性都是驼峰式大小写,属性 class 和 for 分别是 className 和 htmlFor,以匹配 DOM API 规范。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-20
    • 1970-01-01
    • 1970-01-01
    • 2021-02-19
    • 2020-03-15
    相关资源
    最近更新 更多