如果是一个空标签,你可以像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。
网友评论