美文网首页
Uncaught Error: [vue-router] "pa

Uncaught Error: [vue-router] "pa

作者: 媛猿YY | 来源:发表于2021-01-28 15:19 被阅读0次

    报错

    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,
                    }  
                ]
            }
        ]
    });
    

    相关文章

      网友评论

          本文标题:Uncaught Error: [vue-router] "pa

          本文链接:https://www.haomeiwen.com/subject/dzzttltx.html