我是 Vue.js 的新手,我正在嘗試在按鈕中使用 router.push 將其鏈接到我的路由,但是,當我單擊它時,它只會忽略我放入其中的部分字串作為原始路由路徑的一部分:
我的按鈕代碼:
<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>
我的路由器.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;

它可以作業,但是通過這個鏈接(見上圖)而不是 localhost:8080/app/dashboard,有人可以向我解釋為什么它可以作業以及為什么它不去 localhost:8080/app/dashboard?
uj5u.com熱心網友回復:
嵌套路由
請注意,以 開頭的嵌套路徑
/將被視為根路徑。這允許您利用組件嵌套,而無需使用嵌套 URL。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/474336.html
上一篇:如何通過按下按鈕創建計時器分鐘?
下一篇:單擊另一個按鈕后禁用兩個按鈕
