如何在 vue-router 中对路由进行分组 [英] How to group routes in vue-router

查看:253
本文介绍了如何在 vue-router 中对路由进行分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上,我有一个导航,其中包含一些类别和嵌套导航锚.如何在 vue-router 中对这些路由进行分组?我想出的最好方法是为每条路线放置一个元数据,然后按它分组.

On my site I have a navigations with some categories and nested navigation anchors in them. How can I group this routes in vue-router? The best I've come up with is to place for each route a meta and then group by it.

推荐答案

我是这样用的(看那个component: { render: h => h('router-view') }):

I use like this (look that component: { render: h => h('router-view') }):

      {
// =============================================================================
// MAIN LAYOUT ROUTES
// =============================================================================
        path: '',
        component: () => import('./layouts/main/Main.vue'),
        children: [
// =============================================================================
//    Routes
// =============================================================================
          {
            path: '/',
            name: 'home',
            component: () => import('./views/Dashboard.vue'),
          },
// =============================================================================
//    User Routes
// =============================================================================
          {
            path: '/user',
            name: 'user',
            component: { render: h => h('router-view') },
            children: [
              {
                path: 'list',
                name: 'user.list',
                component: () => import('./views/pages/User/List.vue'),
              },
            ]
          },

        ],
      }

这篇关于如何在 vue-router 中对路由进行分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆