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之前还有父路由,道理是一样的,带"/"就不带父,不带"/"就带父。