Vue-router是否支持多级路由?

项目基于Vue全家桶+iView+iView-admin
iView-admin的路由写法如下,我简化了部分代码:

export const appRouter =[
     {
         path: '/access',
         icon: 'key',
         name: 'access',
         title: '权限管理',
         component: Main,
         children: [{
             path: 'index',
             title: '权限管理',
             name: 'access_index',
             component: () =>
                 import ('@/views/access/access.vue')
        }]
     },
     ...
]

export const routers = [
    ...appRouter,
];

// 路由配置
const RouterConfig = {
    // mode: 'history',
    routes: routers
};

export const router = new VueRouter(RouterConfig);

由于1.31版本不支持2级以下的侧边栏菜单,我自己在children字段里加了一个children,如下:

{
    path: '/tourcard',
    icon: 'android-settings',
    name: 'tourcard',
    title: '旅游卡',
    component: Main,
    children: [{
        path: 'tourcard-card',
        title: '旅游卡列表',
        name: 'tourcard-card',
        component: () =>
            import ('@/views/tourcard/tourcard-card/tourcard-main.vue'),
        children: [{
            path: 'tourcard-main',
            title: '旅游卡管理',
            name: 'tourcard-main',
            component: () =>
                import ('@/views/tourcard/tourcard-card/tourcard-card/tourcard-card.vue'),
        }, {
            path: 'tourcard-detail',
            title: '旅游卡明细',
            name: 'tourcard-detail',
            component: () =>
                import ('@/views/tourcard/tourcard-card/tourcard-detail/tourcard-detail.vue')
        }]
    }, {
        path: 'tourcard-saleOrder',
        title: '旅游卡销售订单',
        name: 'tourcard-saleOrder',
        component: () =>
            import ('@/views/tourcard/tourcard-saleOrder/tourcard-saleOrder.vue')
    }]
},

点击侧边栏,页面可以正常跳转,但是控制台会报错,我想问问,这个错误是在哪里呢,是路由那里么?
图片描述

回答:

Main.vue里面的watch

暂无评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注