fix(docs): 为 FooterDoc 组件添加 key 属性避免复用问题
使用 useData 获取当前页面路径,将其作为 key 传递给 FooterDoc 组件,确保在页面切换时组件能正确重新渲染,避免因 Vue 复用导致的显示状态残留。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import DefaultTheme from 'vitepress/theme';
|
||||
import { h } from 'vue';
|
||||
import { useData } from 'vitepress';
|
||||
import FooterDoc from '../components/footerDoc.vue';
|
||||
import GitHubStar from '../components/githubStar.vue';
|
||||
import './custom.css';
|
||||
@@ -8,9 +9,10 @@ export default {
|
||||
...DefaultTheme,
|
||||
Layout() {
|
||||
const Layout = DefaultTheme.Layout;
|
||||
const { page } = useData();
|
||||
|
||||
return h(Layout, null, {
|
||||
'doc-footer-before': () => h(FooterDoc),
|
||||
'doc-footer-before': () => h(FooterDoc, { key: page.value.relativePath }),
|
||||
'nav-bar-content-after': () => h(GitHubStar),
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user