跳至主要內容
vue2自动路由

每次在views下添加页面后,都需要去配置路由,总是手动去设置,会比较麻烦

于是研究了一下根据目录结构自动生成路由,这样在views下添加文件之后就会自动生成路由了

先查看需要的路由结构

const routes = [
    {
        path: '/',
        component: () => import('@/layout/index.vue'),
        children: [
            {
                path: '',
                name: 'index',
                component: () => import('@/views/index.vue')
            }, {
                path: '/test',
                name: 'test',
                component: () => import('@/views/test/index.vue')
            },{
                path: '/test/index',
                name: 'test-test',
                component: () => import('@/views/test/test.vue')
            }
        ]
    },
]

荒芜...大约 2 分钟前端vue2router