introduction.mdx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { PackageManagerTabs } from '@theme';
  2. # 快速上手
  3. ## 如何使用?
  4. ### 通过包引用使用
  5. 官方表单物料可以直接通过包引用使用:
  6. <PackageManagerTabs command="install @flowgram.ai/form-materials" />
  7. ```tsx
  8. import { JsonSchemaEditor } from '@flowgram.ai/form-materials'
  9. ```
  10. ### 通过 CLI 添加物料源代码使用
  11. 如果业务对组件有定制诉求(如:更改文案、样式、业务逻辑),推荐 **通过 CLI 将物料源代码添加到项目中进行定制**:
  12. ```bash
  13. npx @flowgram.ai/cli@latest materials
  14. ```
  15. 运行后 CLI 会提示用户选择要添加到项目中的物料:
  16. ```console
  17. ? Select one material to add: (Use arrow keys)
  18. ❯ components/json-schema-editor
  19. components/type-selector
  20. components/variable-selector
  21. ```
  22. 使用者也可以直接在 CLI 中添加指定物料的源代码:
  23. ```bash
  24. npx @flowgram.ai/cli@latest materials components/json-schema-editor
  25. ```
  26. CLI 运行成功后,相关物料会自动添加到当前项目下的 `src/form-materials` 目录下
  27. :::warning 注意事项
  28. 1. 官方物料目前底层基于 [Semi Design](https://semi.design/) 实现,业务如果有底层组件库的诉求,可以通过 CLI 复制源码进行替换
  29. 2. 一些物料会依赖一些第三方 npm 库,这些库会在 CLI 运行时自动安装
  30. 3. 一些物料会依赖另外一些官方物料,这些被依赖的物料源代码在 CLI 运行时会一起被添加到项目中去
  31. :::