Vue子路由的两种访问方式

113 阅读1分钟

1.第一种:
根路径访问:http://localhost:8080/#/welcome

...
const router = new Router({
  routes: [
    {
      path: '/home',
      component: Home,
      redirect: '/welcome',  //http://localhost:8080/#/welcome
      children: [{
        path: '/welcome',
        component: Welcome
      }, 
   }
...

2.第二种:
通过父级路径访问:http://localhost:8080/#/home/welcome

...
const router = new Router({
  routes: [
    {
      path: '/home',
      component: Home,
      redirect: '/home/welcome',  //http://localhost:8080/#/home/welcome
      children: [{
        path: 'welcome',
        component: Welcome
      }, 
   }
...