[vue-router] Duplicate named routes definition: { name: "home", path: "/home" }

豬豬是天才發表於2018-11-20

背景:vue 專案,路由為 / ,和 /home ,掛載的元件都是同一個,就會在控制檯報警告

[vue-router] Duplicate named routes definition: { name: "home", path: "/home" }

程式碼如下圖:

[vue-router] Duplicate named routes definition: { name: "home", path: "/home" }

解決方法:

{
      path: '/',
      redirect: {
        name: 'home'
      }
    },
    {
      path: '/home',
      name: 'home',
      component: home
    },
複製程式碼

預設開啟 / 就會跳到 /home 頁面


相關文章