vue router 常用操作

1.  普通路由

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

2. 重定向 redirect

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

3. 嵌套路由

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

4. 懒加载

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

猜你喜欢

转载自www.cnblogs.com/zsg88/p/11627363.html
今日推荐