【问题标题】:Is it possible to have children routes and route-views in vuepress?是否可以在 vuepress 中有子路线和路线视图?
【发布时间】:2019-06-11 23:19:35
【问题描述】:

我试图在我的主页中添加一个子路由视图,但在 vuepress 中找不到实现此目的的方法。

这就是我通常在 Vue 中的 router.js 中完成此操作的方式

    routes: [
        {
            path: '/',
            name: 'home',
            component: Home,
            children: [
                {
                    path: '/work/:worktitle',
                    name: 'workpage',
                    // component: () => import(/* webpackChunkName: "about" */ './views/WorkView.vue'),

                    component: WorkView,
                    props: true
                }
            ]
        }
    ]

但我不知道我在哪里可以将这样的代码放在 vuepress 中。 (没有 router.js)

我正在尝试完成此操作,因为我试图在我的主页中拥有一组链接,并且在单击时,我希望将这些链接的页面呈​​现为模式而不进入新页面。但我想保留直接链接到这些模式的能力。

【问题讨论】:

    标签: nested vue-router children vuepress


    【解决方案1】:

    使用.vuepress/enhanceApp.jsrouter.addRoutes

    // async function is also supported, too
    export default ({
      Vue, // the version of Vue being used in the VuePress app
      options, // the options for the root Vue instance
      router, // the router instance for the app
      siteData, // site metadata
      isServer // is this enhancement applied in server-rendering or client
    }) => {
      // ...apply enhancements to the app
      router.addRoutes([
        // ...
      ])
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-17
      • 2011-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-05
      • 1970-01-01
      相关资源
      最近更新 更多