Vue 路由路径问题记录

1.path带"/"
{
  path: "/workbench",
  name: "workbench",
  meta: {
    title: "name",
    icon: "receiving"
  },
  component: () => import(/* webpackChunkName: "dashboard" */ "@/views/workbench"),
  children: [
    {
      path: "/myToDo",
      name: "myToDo",
      meta: {
        title: "name1",
        icon: "receiving"
      },
      component: view("workbench/myToDo"),
    }
  ]
},

  

2.path不带"/"

{
  path: "/workbench",
  name: "workbench",
  meta: {
    title: "name",
    icon: "receiving"
  },
  component: () => import(/* webpackChunkName: "dashboard" */ "@/views/workbench"),
  children: [
    {
      path: "myToDo",
      name: "myToDo",
      meta: {
        title: "name1",
        icon: "receiving"
      },
      component: view("workbench/myToDo"),
    }
  ]
},

  

第一种访问myToDo,this.$toute.path 获取到的path是"/workbench/myToDo"。

第二种访问myToDo,this.$toute.path 获取到的path是"/myToDo"。

如果workbench之前还有父路由,道理是一样的,带"/"就不带父,不带"/"就带父。

 

posted @ 2021-02-19 15:41  玛卡巴鉲  阅读(296)  评论(0编辑  收藏  举报