鍍金池/ 教程/ HTML/ 標簽和屬性支持
顯示數(shù)據(jù)
組件的引用
Controlled Input 值為 null 的情況
Reconciliation
子 props 的類型
組件的詳細說明和生命周期
傳遞 Props
特殊的非 DOM 屬性
組件 API
PureRenderMixin
雙向綁定輔助工具
瀏覽器中的工作原理
深入 JSX
表單組件
Dangerously Set innerHTML
入門
JSX 中的 If-Else
克隆組件
教程
更多的關于Refs
JSX 的 false 處理
高級性能
Mounting 后 componentWillReceiveProps 未被觸發(fā)
簡介
測試工具集
JSX 陷阱
工具集成(ToolingIntegration)
公開組件功能
通過 AJAX 加載初始數(shù)據(jù)
事件系統(tǒng)
可復用組件
this.props.children undefined
不可變數(shù)據(jù)的輔助工具(Immutability Helpers)
動態(tài)交互式用戶界面
組件的 DOM 事件監(jiān)聽
復合組件
動畫
插件
JSX 展開屬性
行內樣式
性能分析工具
類名操作
與其他類庫并行使用 React
鍵控的片段
標簽和屬性支持
組件間的通信
React (虛擬)DOM 術語
JSX 根節(jié)點的最大數(shù)量
在樣式props中快速制定像素值
頂層 API
深入理解 React
自閉合標簽
為什么使用 React?
getInitialState 里的 Props 是一個反模式
與 DOM 的差異

標簽和屬性支持

支持的標簽

React 嘗試支持所用常用的元素。如果你需要的元素沒有在下面列出來,請?zhí)峤灰粋€問題(issue)。

HTML 元素

下列的 HTML 元素是被支持的:

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

SVG 元素

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

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

你或許對 react-art 也感興趣,它是一個為 React 寫的渲染到 Canvas、SVG 或者 VML(IE8) 的繪圖庫。

支持的屬性

React 支持所有 data-*aria-* 屬性,也支持下面列出的屬性。

注意:

所有的屬性都是駝峰命名的,class 屬性和 for 屬性分別改為 classNamehtmlFor,來符合 DOM API 規(guī)范。

對于支持的事件列表,參考支持的事件。

HTML 屬性

這些標準的屬性是被支持的:

accept acceptCharset accessKey action allowFullScreen allowTransparency alt
async autoComplete autoPlay cellPadding cellSpacing charSet checked classID
className cols colSpan content contentEditable contextMenu controls coords
crossOrigin data dateTime defer dir disabled download draggable encType form
formAction formEncType formMethod formNoValidate formTarget frameBorder height
hidden href hrefLang htmlFor httpEquiv icon id label lang list loop manifest
marginHeight marginWidth max maxLength media mediaGroup method min multiple
muted name noValidate open pattern placeholder poster preload radioGroup
readOnly rel required role rows rowSpan sandbox scope scrolling seamless
selected shape size sizes span spellCheck src srcDoc srcSet start step style
tabIndex target title type useMap value width wmode

另外,下面非標準的屬性也是被支持的:

  • autoCapitalize autoCorrect 用于移動端的 Safari。
  • property 用于 Open Graph 原標簽。
  • itemProp itemScope itemType 用于 HTML5 microdata

也有 React 特有的屬性 dangerouslySetInnerHTML更多信息,用于直接插入 HTML 字符串到組件中。

SVG 屬性

cx cy d dx dy fill fillOpacity fontFamily fontSize fx fy gradientTransform
gradientUnits markerEnd markerMid markerStart offset opacity
patternContentUnits patternUnits points preserveAspectRatio r rx ry
spreadMethod stopColor stopOpacity stroke strokeDasharray strokeLinecap
strokeOpacity strokeWidth textAnchor transform version viewBox x1 x2 x y1 y2 y