Skip to content

一级默认路由

javascript
// 创建并暴露 router 实例,用于配置一组一组的路由。
export default new VueRouter({
    routes: [
        {
            name: 'home',
            path: '/home',
            component: Home
        },
        { path: '*', redirect: '/home' }, // 默认路由
    ]
})

二级默认路由 redirect

javascript
export default new VueRouter({
    mode: 'history',
    routes: [{
        path: '/index',
        name: 'index',
        component: Index,
        children: [{
            path: 'booklist',
            name: 'booklist',
            component: BookList
        }],
        redirect: '/index/booklist'
    }]
})

基于 MIT 许可发布