formkit-core-skilld

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

formkit/formkit
@formkit/core

formkit/formkit
@formkit/core

Version: 1.7.2 (Dec 2025) Deps: @formkit/utils@^1.7.2 Tags: perf: 1.0.0-beta.13-c578106 (Nov 2022), dev: 1.7.1-dev.3466e73 (Dec 2025), latest: 1.7.2 (Dec 2025), next: 1.7.2-next.296355 (Dec 2025)
References: Docs — API reference, guides • GitHub Issues — bugs, workarounds, edge cases • GitHub Discussions — Q&A, patterns, recipes • Releases — changelog, breaking changes, new APIs
**版本:**1.7.2(2025年12月) 依赖:@formkit/utils@^1.7.2 **标签:**perf: 1.0.0-beta.13-c578106(2022年11月),dev: 1.7.1-dev.3466e73(2025年12月),latest: 1.7.2(2025年12月),next: 1.7.2-next.296355(2025年12月)
参考链接:文档 — API参考、指南 • GitHub问题 — bug、解决方案、边缘案例 • GitHub讨论 — 问答、模式、实践方案 • 版本发布 — 更新日志、重大变更、新API

API Changes

API变更

This section documents version-specific API changes — prioritize recent major/minor releases.
  • NEW:
    useFormKitContext()
    — v1.6.0, access parent context with optional effect callback source
  • NEW:
    useFormKitContextById()
    — v1.6.0, access any context by its explicit id source
  • NEW:
    useFormKitNodeById()
    — v1.6.0, access any node by its explicit id source
  • NEW:
    stopWatch()
    — v1.6.0, de-registers receipts from the
    watchRegistry
    function source
  • NEW:
    library
    prop — v1.6.0, adds additional components to the input schema for sections-schema source
  • NEW:
    createInput
    — v1.5.0, third argument
    sectionsSchema
    allows extending default sections source
  • NEW:
    didMount
    /
    mounted
    — v1.5.0, context property and node event to detect DOM mounting source
  • NEW:
    changeLocale()
    — v1.5.0, globally change locale for all forms across multiple APIs source
  • NEW:
    date_after_node
    — v1.7.0, compare date against another field; also
    date_before_node
    source
  • NEW:
    passing
    state — v1.6.3,
    context.state.passing
    indicates if input satisfies validation rules source
  • NEW:
    minAutoHeight
    — v1.7.0, prop for auto-height textarea addon to respect CSS min-height source
  • BREAKING:
    @formkit/vue
    — v1.6.0, Vue is now a peer dependency to avoid multiple instance issues source
  • DEPRECATED: Genesis CSS theme — v1.5.0, marked as legacy; use Tailwind themes instead source
  • NEW:
    mergeStrategy
    (experimental) — v1.6.1, syncs two nodes of same name in same parent (experimental) source
Also changed:
getNode<T>()
generic v1.6.0 · Boolean props shorthand v1.5.0 ·
summaryHeader
i18n v1.7.0 ·
node.children
reactivity v1.5.0 ·
FormKitTypeDefinition
inference v1.6.0 ·
themes
peer deps removed v1.7.1
本部分记录特定版本的API变更——优先查看近期的主版本/次版本更新。
  • 新增:
    useFormKitContext()
    — v1.6.0版本,可通过可选的effect回调访问父级上下文 来源
  • 新增:
    useFormKitContextById()
    — v1.6.0版本,可通过明确的id访问任意上下文 来源
  • 新增:
    useFormKitNodeById()
    — v1.6.0版本,可通过明确的id访问任意节点 来源
  • 新增:
    stopWatch()
    — v1.6.0版本,从
    watchRegistry
    函数中注销回执 来源
  • 新增:
    library
    属性 — v1.6.0版本,为sections-schema的输入架构添加额外组件 来源
  • 新增:
    createInput
    — v1.5.0版本,第三个参数
    sectionsSchema
    允许扩展默认区块 来源
  • 新增:
    didMount
    /
    mounted
    — v1.5.0版本,用于检测DOM挂载的上下文属性和节点事件 来源
  • 新增:
    changeLocale()
    — v1.5.0版本,通过多个API全局更改所有表单的语言环境 来源
  • 新增:
    date_after_node
    — v1.7.0版本,将日期与另一个字段进行比较;同时新增
    date_before_node
    来源
  • 新增:
    passing
    状态 — v1.6.3版本,
    context.state.passing
    表示输入是否满足验证规则 来源
  • 新增:
    minAutoHeight
    — v1.7.0版本,自动高度文本框插件的属性,用于遵循CSS最小高度设置 来源
  • 重大变更:
    @formkit/vue
    — v1.6.0版本,Vue现在是peer依赖,以避免多实例问题 来源
  • 已废弃:Genesis CSS主题 — v1.5.0版本,标记为遗留主题;请改用Tailwind主题 来源
  • 新增:
    mergeStrategy
    (实验性) — v1.6.1版本,同步同一父级下同名的两个节点(实验性) 来源
其他变更:
getNode<T>()
泛型 v1.6.0 · 布尔属性简写 v1.5.0 ·
summaryHeader
国际化 v1.7.0 ·
node.children
响应式 v1.5.0 ·
FormKitTypeDefinition
类型推断 v1.6.0 ·
themes
peer依赖移除 v1.7.1

Best Practices

最佳实践

  • Read resolved configuration and prop data from
    node.props
    rather than
    node.config
    — explicit props and parent configurations are automatically merged into the props object source
  • Synchronize multiple inputs with the same name at the same level using the
    mergeStrategy
    config option — prevents value conflicts when identical names are required by template structure source
  • Use
    node.input(value)
    instead of direct assignment to
    node.value
    — ensures the tree's state is tracked and triggers the asynchronous settlement process source
  • Await
    node.settled
    before programmatically reading form values or submitting — guarantees all asynchronous input commits and side effects are complete source
  • Append
    .deep
    to event names in
    node.on()
    to capture events bubbling from descendants — allows parent nodes or plugins to respond to subtree lifecycle changes source
  • Leverage
    node.ledger
    to create reactive, tree-wide counters for messages — efficiently sums message states (like errors or visibility) across complex form structures source
  • Traverse the node tree using
    node.at()
    with special tokens like
    $root
    ,
    $parent
    , and
    $self
    — provides a robust way to access relative nodes without hardcoding absolute paths source
  • Opt out of
    defaultConfig
    in production to enable tree-shaking for unused rules, inputs, and locales — significantly reduces bundle size by manually registering only required features source
  • Register middleware via
    node.hook
    within plugins to intercept core operations — enables reusable logic for transforming props, values, or error messages across multiple forms source
  • Always remove event listeners using the "receipt" returned by
    node.on()
    via
    node.off(receipt)
    — prevents memory leaks and redundant execution in long-lived or dynamic form contexts source
  • node.props
    而非
    node.config
    中读取已解析的配置和属性数据——显式属性和父级配置会自动合并到props对象中 来源
  • 使用
    mergeStrategy
    配置选项同步同一层级下同名的多个输入框——当模板结构要求使用相同名称时,可防止值冲突 来源
  • 使用
    node.input(value)
    而非直接赋值给
    node.value
    ——确保树状状态被跟踪,并触发异步结算流程 来源
  • 在以编程方式读取表单值或提交前,等待
    node.settled
    完成——保证所有异步输入提交和副作用都已完成 来源
  • node.on()
    中的事件名称后追加
    .deep
    ,以捕获来自后代节点的冒泡事件——允许父节点或插件响应子树的生命周期变化 来源
  • 利用
    node.ledger
    创建响应式的树状全局消息计数器——高效汇总复杂表单结构中的消息状态(如错误或可见性) 来源
  • 使用带有
    $root
    $parent
    $self
    等特殊标记的
    node.at()
    遍历节点树——无需硬编码绝对路径,即可可靠地访问相对节点 来源
  • 在生产环境中禁用
    defaultConfig
    ,以对未使用的规则、输入框和语言环境启用摇树优化——通过手动仅注册所需功能,显著减小包体积 来源
  • 在插件中通过
    node.hook
    注册中间件,以拦截核心操作——可实现跨多个表单的属性、值或错误消息转换的可复用逻辑 来源
  • 务必使用
    node.on()
    返回的“回执”,通过
    node.off(receipt)
    移除事件监听器——防止在长期运行或动态表单环境中出现内存泄漏和重复执行 来源