Skip to content

定义

创建虚拟 DOM 节点 (vnode)。

类型

ts
// 完整参数签名
function h(
  type: string | Component, //可以创建原生dom,也可以创建组件
  props?: object | null, // 可以给组件(原生dom)插入文字,添加事件等
  children?: Children | Slot | Slots
): VNode;

// 省略 props
function h(type: string | Component, children?: Children | Slot): VNode;
type Children = string | number | boolean | VNode | null | Children[];
type Slot = () => Children;
type Slots = { [name: string]: Slot };
// 完整参数签名
function h(
  type: string | Component, //可以创建原生dom,也可以创建组件
  props?: object | null, // 可以给组件(原生dom)插入文字,添加事件等
  children?: Children | Slot | Slots
): VNode;

// 省略 props
function h(type: string | Component, children?: Children | Slot): VNode;
type Children = string | number | boolean | VNode | null | Children[];
type Slot = () => Children;
type Slots = { [name: string]: Slot };

渲染原生 dom

渲染组件

h 函数中的 双向数据绑定

使用场景(ant design 表格自定义渲染为例)