重新加载页面时,vue路由器出现问题。
链接http://example.com/admin/home/page1
对此进行更改
http://example.com/admin/home/page1/page1。
vue版本3.9.2 操作系统赢10 x64
router.js
const router = new Router({
mode: ‘history’,
base: process.env.VUE_APP_LINK,
routes: [
{
path: ‘/home’,
name: ‘home’,
component: Home,
children: [
{
path: ‘page1’,
name: ‘page1’,
component: () => import(’@/components/contents/page1.vue’),
},
{
path: ‘page2’,
name: ‘page2’,
component: () => import(’@/components/tools/page2.vue’),
},
{
path: ‘page3’,
name: ‘page3’,
component: () => import(’@/components/contents/page3.vue’),
},
{
path: ‘page4’,
name: ‘page4’,
component: () => import(’@/components/contents/page4.vue’),
}]},
{
path: ‘/login’,
name: ‘login’,
component: Login
},
{
path: '*',
redirect: '/home/page1'
}
]
})```
<li class="nav-item"><router-link to="page1" class="nav-link">page1</router-link></li>
<li class="nav-item"><router-link to="page2" class="nav-link">page2</router-link></li>
<li class="nav-item"><router-link to="page3" class="nav-link">page3</router-link></li>
<li class="nav-item"><router-link to="page4" class="nav-link">page4</router-link></li>
答案 0 :(得分:0)
尝试在您的/page1
值中使用/home/page1
或page1
而不是path
。