我用的是 vuepress-theme-plume 主题

在 client.ts 文件中引入 router

import { defineClientConfig } from 'vuepress/client'
import './theme/styles/index.css'

export default defineClientConfig({
  enhance({ app, router }) {
    router.afterEach((to, from) => {
      console.log('Route changed from:', from.fullPath, 'to:', to.fullPath);
    });
  },
})

router是自己添加的,之后就可以了。

更多推荐