自定义字段
🌐 Custom Fields
Page summary:
自定义字段通过新的字段类型扩展 Strapi,这些字段在内容类型构建器和内容管理器中表现得像原生字段。本文档中的说明涵盖了通过插件构建或安装字段以及以编程方式注册字段的步骤。
自定义字段通过向内容类型和组件添加新类型的字段来扩展 Strapi 的功能。一旦通过插件创建或添加到 Strapi,自定义字段就可以像内置字段一样在内容类型构建器和内 容管理器中使用。
🌐 Custom fields extend Strapi’s capabilities by adding new types of fields to content-types and components. Once created or added to Strapi via plugins, custom fields can be used in the Content-Type Builder and Content Manager just like built-in fields.
配置
🌐 Configuration
现成的自定义字段可以在 Marketplace 找到。安装后,无需其他配置,即可开始使用它们(参见 使用方法)。
🌐 Ready-made custom fields can be found on the Marketplace. Once installed these, no other configuration is required, and you can start using them (see usage).
你也可以开发自己的自定义字段。
🌐 You can also develop your own custom field.
开发你自己的自定义字段
🌐 Developing your own custom field
虽然推荐的添加自定义字段的方法是通过创建插件,但特定应用的自定义字段也可以在 src/index 和 src/admin/app 文件中找到的全局 register 函数 中注册。
🌐 Though the recommended way to add a custom field is through creating a plugin, app-specific custom fields can also be registered within the global register function found in src/index and src/admin/app files.
- 自定义字段只能使用插件在 Marketplace 上共享和分发。
- 自定义字段不能为 Strapi 添加新的数据类型,必须使用在 模型属性 文档中描述的现有内置 Strapi 数据类型。