常用组件
¥Common components
所有内置的浏览器组件都支持一些属性和事件。
¥All of the built-in browser components support some props and events.
这包括 React 特定的属性,如 ref
和 dangerouslySetInnerHTML
。
¥This includes React-specific props like ref
and dangerouslySetInnerHTML
.
表单组件
¥Form components
这些内置浏览器组件接受用户输入:
¥These built-in browser components accept user input:
它们在 React 中很特别,因为将 value
属性传递给它们会使它们成为 受控。
¥They are special in React because passing the value
prop to them makes them controlled.
资源和元数据组件
¥Resource and Metadata Components
这些内置的浏览器组件允许你加载外部资源或使用元数据注释文档:
¥These built-in browser components let you load external resources or annotate the document with metadata:
它们在 React 中很特殊,因为 React 可以将它们渲染到文档头中,在加载资源时挂起,并执行每个特定组件的参考页面上描述的其他行为。
¥They are special in React because React can render them into the document head, suspend while resources are loading, and enact other behaviors that are described on the reference page for each specific component.
所有 HTML 组件
¥All HTML components
React 支持所有内置的浏览器 HTML 组件。这包括:
¥React supports all built-in browser HTML components. This includes:
自定义 HTML 元素
¥Custom HTML elements
如果你渲染一个带有破折号的标签,比如 <my-element>
,React 会假设你想要渲染一个 自定义 HTML 元素。 在 React 中,渲染自定义元素与渲染内置浏览器标签的工作方式不同:
¥If you render a tag with a dash, like <my-element>
, React will assume you want to render a custom HTML element. In React, rendering custom elements works differently from rendering built-in browser tags:
-
所有自定义元素属性都序列化为字符串,并且始终使用属性进行设置。
¥All custom element props are serialized to strings and are always set using attributes.
-
自定义元素接受
class
而不是className
,以及for
而不是htmlFor
。¥Custom elements accept
class
rather thanclassName
, andfor
rather thanhtmlFor
.
如果你渲染一个带有 is
属性的内置浏览器 HTML 元素,它也将被视为自定义元素。
¥If you render a built-in browser HTML element with an is
attribute, it will also be treated as a custom element.
所有 SVG 组件
¥All SVG components
React 支持所有内置的浏览器 SVG 组件。这包括:
¥React supports all built-in browser SVG components. This includes:
-
<hatch>
-
<hatchpath>