vue router 常用操作 重定向 redirect

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') }
]

版权声明:本文为solocao原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。