VUE之Router命令行警告:Named Route 'Home' has a default child route. 解决办法

Named Route 'Home' has a default child route. When navigating to this named route (:to="{name: 'Home'"), the default child route will not be rendered. Remove the name from this route and use the name of the default child route for named links instead.

报错代码:

    {
      path:'/page/home/Home',
      name:'Home',
      component:Home,
      children:[
        {
          path: '/',
          name: 'HomeCarousel',
          component: HomeCarousel,
        },
      ]
    }

总结警告原因:当某个路由有子级路由时,父级路由需要一个默认的路由,所以父级路由不能定义name属性,解决办法是去掉name:'Home'就可以了

正确代码

    {
      path:'/page/home/Home',
      component:Home,
      children:[
        {
          path: '/',
          name: 'HomeCarousel',
          component: HomeCarousel,
        },
      ]
    }
原文地址:https://www.cnblogs.com/zhixi/p/9640785.html