Loving Tina? us on GitHub0.0k

文档

学习

v.Latest
Documentation
字符串字段
目录

一个用于存储短文本内容的文本输入字段,例如标题或描述。

对于缩进、加粗和其他格式,请使用富文本字段类型

类型定义

有关所有字段类型共有的附加属性,请查看字段类型定义。
REQUIRED
type
string

将此设置为 "string" 以使用字符串字段。


REQUIRED
name
string

供内部使用的字段名称。

All properties marked as REQUIRED must be specified for the field to work properly.

示例

简单字段

{
type: 'string',
name: 'title',
label: 'Title'
}

简单列表字段

设置 list: true 将使值成为数组

{
type: 'string',
name: 'title',
label: 'Title',
list: true
}

带有文本区域组件的字段

默认情况下,文本字段用于字符串。要使用不同的核心字段插件,请通过 ui.component 属性指定。

{
label: "Description",
name: "description",
type: "string",
ui: {
component: "textarea"
}
}

带有自定义组件的字段

您可以为TinaCMS编辑器创建自己的组件来存储字符串类型内容。

{
label: "Title",
name: "title",
type: "string",
ui: {
component: ({ input }) => {
return (
<div>
<label htmlFor="title">Title: </label>
<input {...input}></input>
</div>
);
},
},
}

上次编辑: March 26, 2025