美文网首页
2.4 Specifying Children with JSX

2.4 Specifying Children with JSX

作者: 人头原子弹 | 来源:发表于2017-03-21 22:52 被阅读0次
    If a tag is empty, you may close it immediately with />, like XML:

    如果是一个空标签,你可以像XML那样通过 />快速改变它。

    const element = <img src={user.avatarUrl} />;

    JSX tags may contain children:

    JSX标签也许包含子标签:

    const element = (
       <div>
          <h1>Hello</h1>
          <h2>Good too see you here!</h2>
       </div>);

    Caveat:

    Since JSX is closer to JavaScript than HTML, React DOM uses camelCase property naming convention instead of HTML attribute names.

    JSX比HTML更接近JavaScript,React Dom 使用驼峰属性命名规则替换HTML的属性名称。

    For example, class becomes className in JSX, and tabindex becomes tabIndex.

    例如在JSX里面class变成了className,而tabindex变成了tabIndex。

    相关文章

      网友评论

          本文标题:2.4 Specifying Children with JSX

          本文链接:https://www.haomeiwen.com/subject/uzhynttx.html