diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts index d6045df4e7..b9c6596d01 100644 --- a/packages/client/src/router.ts +++ b/packages/client/src/router.ts @@ -53,6 +53,6 @@ declare module 'vue-router' { * * @internal only for internal use */ - _data: PageData + _data?: PageData } } diff --git a/packages/client/src/setupGlobalComputed.ts b/packages/client/src/setupGlobalComputed.ts index 49c4fa6901..4f914337d2 100644 --- a/packages/client/src/setupGlobalComputed.ts +++ b/packages/client/src/setupGlobalComputed.ts @@ -73,13 +73,13 @@ export const setupGlobalComputed = ( // load page data from route meta const pageData = computedWithControl( routePath, - () => router.currentRoute.value.meta._data, + () => router.currentRoute.value.meta._data!, ) // handle page data HMR if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) { __VUE_HMR_RUNTIME__.updatePageData = (data: PageData) => { pagesData.value[data.key] = () => Promise.resolve(data) - if (data.key === router.currentRoute.value.meta._data.key) { + if (data.key === router.currentRoute.value.meta._data?.key) { router.currentRoute.value.meta._data = data pageData.trigger() }