@formcrafts/embed

中文文档
1.0.40发布于 2026/09/21MITTypeScriptESM + CJS零依赖近 30 天下载 9809

嵌入表格的库

中文使用文档
文档目录9 节
  1. 导言
  2. 安装
  3. 导入库
  4. 嵌入 - 内置
  5. 初始化表单
  6. 可用方法
  7. 嵌入 - 弹出
  8. 初始化表单
  9. 可用方法

导言

你可以使用Formcrafts的嵌入库 @formcrafts/embed 以 Vanilla JavaScript 为格式嵌入。 库可作为一个npm软件包提供,与Svelte,React,Vue,Angular等框架合作良好.

安装

要将 Formcraps JavaScript 库添加到您的项目中, 请使用 npm 安装 :

npm install @formcrafts/embed --save

导入库

要在代码中提供库,请导入必要的模块:

import { createInlineForm, createPopup } from "@formcrafts/embed"

嵌入 - 内置

初始化表单

const myInlineForm = createInlineForm({
  form: "form_key", // Your form key
  target: document.getElementById("element_id"), // Target element
  seamless: true, // Removes form border, shadow, and padding
  width: 500, // Max width of the form
  redirectWithin: true, // Keep redirect within form frame
  values: {
    field1: "Jack Smith",
    field2: ["Chocolate", "Vanilla"],
  }, // Prefill values
})

可用方法

您可以使用下列方法与内线形式进行交互:

myInlineForm.on("load", (height: number) => {}) // Fires when the form loads
myInlineForm.on("submit:success", () => {}) // Fires on a successful form submit
myInlineForm.destroy() // Remove the form instance
myInlineForm.values({
  field1: "New value",
}) // Update the values of the form

嵌入 - 弹出

初始化表单

const myPopupForm = createPopup({
  form: "form_key", // Your form key
  width: 500, // Max width of the form
  redirectWithin: true, // Keep redirect within form frame
  values: {
    field1: "Jack Smith",
    field2: ["Chocolate", "Vanilla"],
  }, // Prefill values
})

可用方法

您可以使用下列方法与弹出表进行交互:

myPopupForm.on("load", (height: number) => {}) // Fires when the form loads
myPopupForm.on("submit:success", () => {}) // Fires on a successful form submit
myPopupForm.load() // Load the form. Can be used to load the form before showing it. Optional.
myPopupForm.open() // Open the popup
myPopupForm.close() // Close the popup
myPopupForm.destroy() // Destroy the popup and the form instance
myPopupForm.values({
  field1: "New value",
}) // Update the values of the form

版本与发布记录

@formcrafts/embed 共发布 48 个版本,首次发布于 2024/02/01;过去 12 个月发布了 2 个版本。

版本发布日期距今
1.0.40latest2026/09/211 个月前
1.0.392026/09/032 个月前
1.0.382025/10/301 年前
1.0.372025/09/181.2 年前
1.0.362025/09/181.2 年前
1.0.352025/08/201.2 年前

关于 @formcrafts/embed 的常见问题

@formcrafts/embed 是什么?

嵌入表格的库

如何安装 @formcrafts/embed?

在项目目录运行 npm install @formcrafts/embed,或使用 pnpm add / yarn add / bun add。

@formcrafts/embed 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@formcrafts/embed 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@formcrafts/embed 可以商用吗?

@formcrafts/embed 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@formcrafts/embed 的下载量有多少?

根据 npm 官方下载统计,@formcrafts/embed 在 2026/10/16 – 2026/11/14 这 30 天内被下载 9,809 次,日均约 327 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@formcrafts/embed 还在维护吗?

最新版本 1.0.40 发布于 2026/09/21(1 个月前);至今共发布 48 个版本,其中过去 12 个月发布了 2 个;首次发布于 2024/02/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。