Skip to content

Runtime API Examples

发表于
更新于
字数
阅读量

This page demonstrates usage of some of the runtime APIs provided by VitePress.

The main useData() API can be used to access site, theme, and page data for the current page. It works in both .md and .vue files:

md
<script setup>
import { useData } from 'vitepress'

const { theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>

Results

Theme Data

{
  "logo": "/shuze2.svg",
  "nav": [
    {
      "text": "文档主页",
      "link": "/"
    },
    {
      "text": "操作指南",
      "link": "/guide/shuze-login"
    },
    {
      "text": "在建水务工程",
      "link": "/watersupervision/00"
    },
    {
      "text": "防御与应急",
      "link": "/disasterprevention/01"
    },
    {
      "text": "设计与计算",
      "link": "/engineeringservice/01"
    },
    {
      "text": "项目结算",
      "link": "/projectmanagement/01-introduction"
    },
    {
      "text": "学习积累",
      "link": "/indal/yunMigration"
    }
  ],
  "sidebar": {
    "/guide/": [
      {
        "text": "操作指南",
        "items": [
          {
            "text": "登录",
            "link": "/guide/shuze-login"
          },
          {
            "text": "api-examples",
            "link": "/api-examples"
          },
          {
            "text": "markdown-examples",
            "link": "/markdown-examples"
          }
        ]
      }
    ],
    "/disasterprevention/": [
      {
        "text": "防御与应急",
        "items": [
          {
            "text": "介绍",
            "link": "/disasterprevention/01"
          }
        ]
      }
    ],
    "/engineeringservice/": [
      {
        "text": "设计与计算",
        "items": [
          {
            "text": "弹性地基梁",
            "link": "/engineeringservice/ElasticFoundationBeam"
          },
          {
            "text": "明钢管结构",
            "link": "/engineeringservice/PenstockDesign"
          },
          {
            "text": "带弹性地基梁平面框架内力计算",
            "link": "/engineeringservice/PlaneFrame"
          },
          {
            "text": "水闸",
            "link": "/engineeringservice/Sluice"
          },
          {
            "text": "水闸渗流",
            "link": "/engineeringservice/SluiceSeepage"
          },
          {
            "text": "明槽恒定均匀流",
            "link": "/engineeringservice/SteadyUniformFlow"
          },
          {
            "text": "水锤计算",
            "link": "/engineeringservice/WaterHammer"
          },
          {
            "text": "大体积砼温控计算",
            "link": "/engineeringservice/ConcreteTemperatureSolution"
          },
          {
            "text": "溢洪道泄流能力",
            "link": "/engineeringservice/DischargeCapacity"
          },
          {
            "text": "埋地管道计算",
            "link": "/engineeringservice/PipeStructuralDesign"
          }
        ]
      }
    ],
    "/projectmanagement/": [
      {
        "text": "项目结算",
        "items": [
          {
            "text": "介绍",
            "link": "/projectmanagement/01-introduction"
          },
          {
            "text": "基础及历史数据导入",
            "link": "/projectmanagement/02-import"
          },
          {
            "text": "项目及任务",
            "link": "/projectmanagement/03-project"
          },
          {
            "text": "项目人员及组建",
            "link": "/projectmanagement/04-staff"
          },
          {
            "text": "项目考勤",
            "link": "/projectmanagement/05-settle"
          },
          {
            "text": "考勤汇总",
            "link": "/projectmanagement/06-sigma"
          }
        ]
      }
    ],
    "/watersupervision/": [
      {
        "text": "在建水务工程",
        "items": [
          {
            "text": "总体要求",
            "link": "/watersupervision/00"
          },
          {
            "text": "01人员履职",
            "link": "/watersupervision/01perform-duties"
          },
          {
            "text": "02风险管控",
            "link": "/watersupervision/02risk"
          },
          {
            "text": "03防洪度汛与应急管理",
            "link": "/watersupervision/03flood-control"
          },
          {
            "text": "04违规违章行为",
            "link": "/watersupervision/04illegal"
          },
          {
            "text": "05危大工程",
            "link": "/watersupervision/05dangerous-project"
          },
          {
            "text": "06特种作业",
            "link": "/watersupervision/06special-operations"
          },
          {
            "text": "07安全防护",
            "link": "/watersupervision/07protective-equipment"
          },
          {
            "text": "08临时用电及消防安全",
            "link": "/watersupervision/08electricity"
          },
          {
            "text": "09文明施工",
            "link": "/watersupervision/10civilized-construction"
          },
          {
            "text": "10实名制分账制",
            "link": "/watersupervision/09realname"
          },
          {
            "text": "11其它-监理要求",
            "link": "/watersupervision/11Supervision"
          },
          {
            "text": "12重大隐患判定",
            "link": "/watersupervision/12hazard"
          },
          {
            "text": "13安全生产管理违规行为分类标准",
            "link": "/watersupervision/13security-violations"
          },
          {
            "text": "14质量管理",
            "link": "/watersupervision/14quality"
          },
          {
            "text": "15市政安全通用规范",
            "link": "/watersupervision/15common"
          },
          {
            "text": "介绍",
            "link": "/guide/shuze-introduction"
          },
          {
            "text": "操作",
            "link": "/guide/shuze-operate"
          }
        ]
      }
    ],
    "/indal/": [
      {
        "text": "学习积累",
        "items": [
          {
            "text": "云服务器迁移流程",
            "link": "/indal/yunMigration"
          },
          {
            "text": "阿里云镜像",
            "link": "/indal/alimirror"
          },
          {
            "text": "nuget包",
            "link": "/indal/baget"
          },
          {
            "text": "docker",
            "link": "/indal/docker"
          },
          {
            "text": "nginx",
            "link": "/indal/nginx"
          },
          {
            "text": "keycloak",
            "link": "/indal/keycloak"
          },
          {
            "text": "gitee",
            "link": "/indal/gitee"
          },
          {
            "text": "ubuntu",
            "link": "/indal/ubuntu"
          },
          {
            "text": "abp",
            "link": "/indal/abp"
          },
          {
            "text": "abp-module",
            "link": "/indal/abp-module"
          },
          {
            "text": "vue",
            "link": "/indal/vue"
          },
          {
            "text": "jmeter",
            "link": "/indal/jmeter"
          },
          {
            "text": "K8s",
            "link": "/indal/k8s"
          },
          {
            "text": "大模型测试",
            "link": "/indal/bigModel"
          }
        ]
      }
    ]
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/vuejs/vitepress"
    }
  ],
  "lastUpdated": {
    "text": "最后更新",
    "formatOptions": {
      "dateStyle": "short",
      "timeStyle": "short"
    }
  },
  "outline": {
    "level": [
      1,
      3
    ]
  },
  "outlineTitle": "页面内容",
  "docFooter": {
    "prev": "上一页",
    "next": "下一页"
  },
  "footer": {
    "message": "<a href=\"https://beian.miit.gov.cn/\"  target=\"_blank\" >粤ICP备2022150451号 </a>",
    "copyright": "Copyright © 2017-2026 澍泽®"
  },
  "search": {
    "provider": "local",
    "options": {
      "translations": {
        "button": {
          "buttonText": "搜索文档",
          "buttonAriaLabel": "搜索文档"
        },
        "modal": {
          "noResultsText": "无法找到相关结果",
          "resetButtonTitle": "清除查询条件",
          "footer": {
            "selectText": "选择",
            "navigateText": "切换"
          }
        }
      }
    }
  },
  "search2": {
    "provider": "algolia",
    "options": {
      "appId": "<Application ID>",
      "apiKey": "<Search-Only API Key>",
      "indexName": "<INDEX_NAME>",
      "locales": {
        "root": {
          "placeholder": "搜索文档",
          "translations": {
            "button": {
              "buttonText": "搜索文档",
              "buttonAriaLabel": "搜索文档"
            },
            "modal": {
              "searchBox": {
                "resetButtonTitle": "清除查询条件",
                "resetButtonAriaLabel": "清除查询条件",
                "cancelButtonText": "取消",
                "cancelButtonAriaLabel": "取消"
              },
              "startScreen": {
                "recentSearchesTitle": "搜索历史",
                "noRecentSearchesText": "没有搜索历史",
                "saveRecentSearchButtonTitle": "保存至搜索历史",
                "removeRecentSearchButtonTitle": "从搜索历史中移除",
                "favoriteSearchesTitle": "收藏",
                "removeFavoriteSearchButtonTitle": "从收藏中移除"
              },
              "errorScreen": {
                "titleText": "无法获取结果",
                "helpText": "你可能需要检查你的网络连接"
              },
              "footer": {
                "selectText": "选择",
                "navigateText": "切换",
                "closeText": "关闭",
                "searchByText": "搜索提供者"
              },
              "noResultsScreen": {
                "noResultsText": "无法找到相关结果",
                "suggestedQueryText": "你可以尝试查询",
                "reportMissingResultsText": "你认为该查询应该有结果?",
                "reportMissingResultsLinkText": "点击反馈"
              }
            }
          }
        }
      }
    }
  }
}

Page Data

{
  "title": "Docs with VitePress",
  "description": "",
  "frontmatter": {
    "outline": "deep",
    "title": "Docs with VitePress",
    "editLink": true,
    "lastUpdated": true
  },
  "headers": [],
  "relativePath": "api-examples.md",
  "filePath": "api-examples.md",
  "lastUpdated": 1754061515000,
  "createdTime": "2025-08-01T23:18:35+08:00"
}

Page Frontmatter

{
  "outline": "deep",
  "title": "Docs with VitePress",
  "editLink": true,
  "lastUpdated": true
}

More

Check out the documentation for the full list of runtime APIs.

最后更新: