深色模式
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><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
{
"nav": [
{
"text": "首页",
"link": "/",
"activeMatch": "/$"
},
{
"text": "量子计算",
"link": "/qc/intro",
"activeMatch": "/qc/"
},
{
"text": "数学参考",
"link": "/math/test",
"activeMatch": "/math/"
}
],
"footer": {
"copyright": "Copyright © Axton Yao"
},
"lastUpdated": {
"text": "更新于 "
},
"sidebar": [
{
"text": "量子计算",
"items": [
{
"text": "量子计算简介",
"link": "/qc/intro"
},
{
"text": "狄拉克符号及量子电路",
"link": "/qc/braket"
},
{
"text": "量子门",
"link": "/qc/gate"
}
]
},
{
"text": "数学参考",
"items": [
{
"text": "Markdown Examples",
"link": "/math/test"
},
{
"text": "Runtime API Examples",
"link": "/api-examples"
}
]
}
],
"outlineTitle": "本页目录",
"docFooter": {
"prev": "上一页",
"next": "下一页"
},
"externalLinkIcon": true,
"returnToTopLabel": "返回页首",
"sidebarMenuLabel": "总览目录",
"darkModeSwitchLabel": "深色模式",
"search": {
"provider": "local",
"options": {
"detailedView": true,
"locales": {
"root": {
"translations": {
"placeholder": "搜索文档",
"button": {
"buttonText": "搜索文档…",
"buttonAriaLabel": "搜索文档"
},
"modal": {
"noResultsText": "没有找到结果:",
"resetButtonTitle": "清空输入",
"displayDetails": "显示详细结果",
"footer": {
"selectText": "选定",
"navigateText": "浏览",
"closeText": "关闭"
}
}
}
}
}
}
},
"notFound": {
"title": "测量不到页面",
"quote": "彷徨于希尔伯特空间,线性叠加隐约。本征值求解未果,比特观测不知。",
"linkText": "坍缩至首页",
"linkLabel": "返回首页"
},
"editLink": {
"pattern": "https://github.com/yrccondor/quantum-computing-101/edit/master/docs/:path",
"text": "通过 Github 帮助编辑此页"
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md",
"lastUpdated": 1699756549000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.