vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.43k stars 4.79k forks source link

Uncaught (in promise) Error: pageData() is called without provider. #3197

Closed GentleGhostCoder closed 5 months ago

GentleGhostCoder commented 5 months ago

Bug report

vue-router.mjs:3471 Error: pageData() is called without provider.
    at usePageData (chunk-DHNSDB55.js?v=057606df:30:11)
    at resolveArraySidebarItems (useSidebarItems.js?v=057606df:79:18)
    at resolveSidebarItems (useSidebarItems.js?v=057606df:44:16)
    at useSidebarItems.js?v=057606df:24:41
    at ReactiveEffect.fn (reactivity.esm-bundler.js:990:13)
    at ReactiveEffect.run (reactivity.esm-bundler.js:176:19)
    at get value [as value] (reactivity.esm-bundler.js:1000:61)
    at triggerComputed (reactivity.esm-bundler.js:195:19)
    at get dirty [as dirty] (reactivity.esm-bundler.js:148:11)
    at get value [as value] (reactivity.esm-bundler.js:999:41)
triggerError @ vue-router.mjs:3471
(anonymous) @ vue-router.mjs:3508
Promise.catch (async)
handleScroll @ vue-router.mjs:3508
finalizeNavigation @ vue-router.mjs:3354
(anonymous) @ vue-router.mjs:3218
Promise.then (async)
pushWithRedirect @ vue-router.mjs:3185
push @ vue-router.mjs:3110
navigate @ vue-router.mjs:2196
callWithErrorHandling @ runtime-core.esm-bundler.js:193
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:201
invoker @ runtime-dom.esm-bundler.js:671
Show 11 more frames

Steps to reproduce

After the steps from the guide have been completed (https://v2.vuepress.vuejs.org/guide/getting-started.html#manual-installation).

  1. Create 2 pages with some subheaders. E.g.:
    
    # MainPage

Subheader

This is a test page.

and

OtherPage

Subheader

This is a test page.


2. Create a config.js as follows:
```js
import {defaultTheme, defineUserConfig} from 'vuepress';

export default defineUserConfig({
        theme: defaultTheme({
                    sidebar: [
                        {
                            text: "Page",
                            link: "/"
                        },
                        {
                            text: "Page1",
                            link: "/page1",

                        },
                        {
                            text: "Page2",
                            link: "/page2",

                        }
                    ],
        }),
})
  1. Run the vuepress in DEV (or build it and run with serve).

    • vuepress dev docs
    • vuepress build docs && npx serve docs/.vuepress/dist/
  2. After click a subheader in the sidebar the error occur.

What is expected?

I expect to change between the subheader in the sidebar without error.

What is actually happening?

After switching between the pages and click on a subheader i can switch the pages correctly anymore.

Click on subheader... image

Switch to other... (still MainPage Sidebar is open). image

webYangFeng commented 5 months ago

How did you solve it

GentleGhostCoder commented 5 months ago

I use the "next" dependencies instead 2.0.0-rc.0. For some reason it fixed the problem. I also closed the ticket because the repo is only for vuepress v1 (as I understand it).