Tags 和属性

支持的 Tags

React 试着支持所有常见的元素。如果你需要一个没有列在这里的元素,请 file an issue

HTML 元素

下面的 HTML 是被支持的:

  1. a abbr address area article aside audio b base bdi bdo big blockquote body br
  2. button canvas caption cite code col colgroup data datalist dd del details dfn
  3. dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5
  4. h6 head header hr html i iframe img input ins kbd keygen label legend li link
  5. main map mark menu menuitem meta meter nav noscript object ol optgroup option
  6. output p param picture pre progress q rp rt ruby s samp script section select
  7. small source span strong style sub summary sup table tbody td textarea tfoot th
  8. thead time title tr track u ul var video wbr

SVG 元素

下面的 SVG 元素是被支持的:

  1. circle clipPath defs ellipse g line linearGradient mask path pattern polygon polyline
  2. radialGradient rect stop svg text tspan

你也许对 react-art有兴趣,一个让React绘制Canvas, SVG, 或者 VML (for IE8) 的绘制库.

支持的属性

React支持所有的 data-*aria-* 以及下列的属性.

注意:

所有的属性都是 camel-cased ,classfor 分别是 classNamehtmlFor,来符合DOM API 规范.

关于事件的列表,见 Supported Events.

HTML 属性

下面的标准属性是被支持的:

  1. accept acceptCharset accessKey action allowFullScreen allowTransparency alt
  2. async autoComplete autoFocus autoPlay capture cellPadding cellSpacing charSet
  3. challenge checked classID className cols colSpan content contentEditable contextMenu
  4. controls coords crossOrigin data dateTime defer dir disabled download draggable
  5. encType form formAction formEncType formMethod formNoValidate formTarget frameBorder
  6. headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode
  7. keyParams keyType label lang list loop low manifest marginHeight marginWidth max
  8. maxLength media mediaGroup method min minLength multiple muted name noValidate open
  9. optimum pattern placeholder poster preload radioGroup readOnly rel required role
  10. rows rowSpan sandbox scope scoped scrolling seamless selected shape size sizes
  11. span spellCheck src srcDoc srcSet start step style summary tabIndex target title
  12. type useMap value width wmode wrap

另外,支持下面的非标准属性:

  • autoCapitalize autoCorrect for Mobile Safari.
  • property for Open Graph meta tags.
  • itemProp itemScope itemType itemRef itemID for HTML5 microdata.
  • unselectable for Internet Explorer.
  • results autoSave for WebKit/Blink input fields of type search.

同样有React规范的属性 dangerouslySetInnerHTML (more here),用于直接插入HTML字符串到组件里.

SVG 属性

  1. clipPath cx cy d dx dy fill fillOpacity fontFamily
  2. fontSize fx fy gradientTransform gradientUnits markerEnd
  3. markerMid markerStart offset opacity patternContentUnits
  4. patternUnits points preserveAspectRatio r rx ry spreadMethod
  5. stopColor stopOpacity stroke strokeDasharray strokeLinecap
  6. strokeOpacity strokeWidth textAnchor transform version
  7. viewBox x1 x2 x xlinkActuate xlinkArcrole xlinkHref xlinkRole
  8. xlinkShow xlinkTitle xlinkType xmlBase xmlLang xmlSpace y1 y2 y