vue router 常用操作 重定向 redirect

版权声明:转载请评论留言 https://blog.csdn.net/solocao/article/details/82901351

1、重定向 redirect

const routes = [
    { path: '/', redirect: '/index'},
    { path: '/index', component: index }
]

2、嵌套路由

const routes = [
    { path: '/index', component: index,
        children: [
            { path: 'info', component: info}
        ]
     }
]

通过/index/info就可以访问到info组件了

3、懒加载

const routes = [
    { path: '/index', component: () => import('@/views/index.vue')},
    { path: '/hello', component: () => import('@/views/hello.vue') }
]

猜你喜欢

转载自blog.csdn.net/solocao/article/details/82901351