有一个 Vue index.js 路由器:
routes: [
path: "/",
name: "main",
component: Main,
children: [
{
path: 'clients',
name: 'clients',
component: ClientsSettings
},
{
path: 'pm-area',
name: 'pm-area',
component: PmArea,
children: [
{
path: 'create-project',
name: 'create-project',
component: Clientrequest
}
]
},
]
]
如果我在代码中使用转换clients或pm-area帮助this.$router.push('clients'), this.$router.push('pm-area'),那么我可以轻松地从一个组件切换到另一个组件。但是如果我指定了路径this.$router.push('pm-area/create-project),那么我会去这个组件,但是从它的帮助下,例如,this.$router.push('clients)我不会进入 Clients 组件,因为路径将是下面的localhost:3001/pm-area/clients,但它应该是localhost:3001/clients。在这种路径嵌套的情况下,如何在组件之间导航?
您的所有路线都已命名。问题是什么?
您正在指定一个相对路径,但您想获得一个绝对路径。