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: '标题'
}

简单列表字段

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

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

带有文本区域组件的字段

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

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

带有自定义组件的字段

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

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

上次编辑: September 18, 2025