为什么我的 router.push 忽略了我的部分路线路径?浏览器
Why my router.push is ignoring part of my route path? VueJs
我是 Vue.js 的新手,我想在我的按钮中使用 router.push 来 link 它到我的路线,但是,当我点击它时,它只是忽略了我作为原始路由路径的一部分放入其中的部分字符串:
我的按钮代码:
<div style="text-align: center; justifyContent: center; display: flex;">
<Button label="Entrar" class="p-3 text-xl" style="width: 250px"
@click="$router.push('app/dashboard')"></button>
</div>
我的router.js:
const routes = [
{
path: '/',
name:'login_page',
component: () => import('@/pages/Login')
},
{
path: '/app',
name: 'app',
component: App,
children: [
{
path: '/dashboard',
name: 'dashboard',
component: () => import('./components/Dashboard.vue')
}
]
}
];
const router = createRouter({
history: createWebHashHistory(),
routes,
});
export default router;
它有效,但是用这个 link(见上图)而不是 localhost:8080/app/dashboard,有人可以向我解释为什么它有效以及为什么它不会localhost:8080/app/dashboard?
Note that nested paths that start with /
will be treated as a root path. This allows you to leverage the component nesting without having to use a nested URL.
我是 Vue.js 的新手,我想在我的按钮中使用 router.push 来 link 它到我的路线,但是,当我点击它时,它只是忽略了我作为原始路由路径的一部分放入其中的部分字符串:
我的按钮代码:
<div style="text-align: center; justifyContent: center; display: flex;">
<Button label="Entrar" class="p-3 text-xl" style="width: 250px"
@click="$router.push('app/dashboard')"></button>
</div>
我的router.js:
const routes = [
{
path: '/',
name:'login_page',
component: () => import('@/pages/Login')
},
{
path: '/app',
name: 'app',
component: App,
children: [
{
path: '/dashboard',
name: 'dashboard',
component: () => import('./components/Dashboard.vue')
}
]
}
];
const router = createRouter({
history: createWebHashHistory(),
routes,
});
export default router;
它有效,但是用这个 link(见上图)而不是 localhost:8080/app/dashboard,有人可以向我解释为什么它有效以及为什么它不会localhost:8080/app/dashboard?
Note that nested paths that start with
/
will be treated as a root path. This allows you to leverage the component nesting without having to use a nested URL.