Uncaught Error: [vue-router] "pa

2021-01-28  本文已影响0人  媛猿YY

报错

Uncaught Error: [vue-router] "path" is required in a route configuration.

原因

在router.js配置路由时,不能写空{},在程序里写了空{}是不报错的,运行是扫描{}中没有path时会报错

写了空{}会报错

routes: [
        {
            path: '/',
            name: 'home',
            component: Home,
            redirect: '/index',
            children: [
                {
                    path: '/index',
                    name: 'index',
                    component: Index,
                }  
            ]
        },
        {}
    ]
});

正确的写法

routes: [
        {
            path: '/',
            name: 'home',
            component: Home,
            redirect: '/index',
            children: [
                {
                    path: '/index',
                    name: 'index',
                    component: Index,
                }  
            ]
        }
    ]
});
上一篇下一篇

猜你喜欢

热点阅读