顶层 API - F2
下一篇
组件 - Component
Loading...
提供了用于处理 this.props.children 的方法
类似 Array.map 遍历并返回新的对象
import { Children } from '@antv/f2';Children.map(this.props.children, (child) => {// TODOreturn child;});
复制一个新元素
import { Children } from '@antv/f2';Children.map(this.props.children, (child) => {return Children.cloneElement(child, { ... });});
转换成数组
import { Children } from '@antv/f2';const childrenArray = Children.toArray(children);
提供生成 jsx 元素的方法,createElement(type, props, ...children)
和 jsx(type, props, ...children)
是完全一致的
import { createElement, Chart } from '@antv/f2';// 创建 chart 元素const element = createElement(Chart, { data }, [...]);
提供了创建 ref 的方法
import { createRef } from '@antv/f2';// 创建 chart 元素const ref = createRef(); // 生成 { current: null } 这样的结构