字段
大约 1 分钟
在你的 VuePress 站点中描述对象的字段。
配置
import { hopeTheme } from "vuepress-theme-hope";
export default hopeTheme({
markdown: {
fields: true,
},
});语法
使用 fields 容器描述字段。以 @ 开头并紧接行内代码的每一行是一个字段项,其属性紧跟反引号之后。
::: fields
@`theme` type=`ThemeConfig` required default=`{ base: '/' }`
主题配置。
@`enabled` type=boolean optional default=`true`
是否启用。
:::所有属性都会被允许并原样展示。常见属性如下:
type会在字段头部以代码块展示。default会在字段头部下方以带标签的代码块展示。required、optional与deprecated会以徽章展示,被弃用的字段名会显示为红色并带有删除线。- 其他属性会以
名称: 值的徽章展示。
嵌套
若要描述对象类型的字段,可以在另一个字段项内部嵌套字段,每增加一层嵌套,开头的 @ 就增加一个。
::: fields
@`options` type=object
选项。
@@`options.name` type=string
选项名称。
:::演示
theme必填
ThemeConfig默认值
{ base: '/' }主题配置。
enabled可选
boolean默认值
true是否启用。
legacy已弃用
string已弃用字段。
Demo
::: fields
@`theme` type=`ThemeConfig` required default=`{ base: '/' }`
主题配置。
@`enabled` type=boolean optional default=`true`
是否启用。
@`legacy` type=string deprecated
已弃用字段。
:::更新日志
2026/9/28 12:45
查看所有更新日志
0c1aa-于fc49f-于