[vue-router] Named Route 'Home' has a default child route.


vue-router.esm.js?fe87:16 [vue-router] 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.

routes: [
    {
      path: '/',
      name: 'Home', // 刪除后正常
      component: Home,
      children: [
        {
          path: '/topiclist/:tab',
          component: TopicContent
        },
        {
          path: '',
          redirect: '/topiclist/all'
        }
      ]
    },
}
  • 問題描述

    • 在給路由設置子路由
    • 以及子路由設置默認路由
    • 然后運行拋出上圖錯誤(頁面正常渲染)
  • 問題原因

    • 在設置好子路由,以及子路由的默認路由后,此時子路由是一個路由集
    • 而某個路由有子集路由的時候,該路由需要一個默認的路由且不能定義name屬性。
  • 解決方法

    • 刪除父級路由的name屬性


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM