Vue2下的多级路由

多级路由(多级路由)

  1. 配置路由规则,使用children配置项: 

routes:[
    {
        path:'/about',
        component:About,
    },
    {
        path:'/home',
        component:Home,
        children:[ //通过children配置子级路由
            {
                path:'news', //此处一定不要写:/news  他会自动加上/,然后自动匹配成/home/news
                component:News
            },
            {
                path:'message',//此处一定不要写:/message
                component:Message
            }
        ]
    }
]

 

  1. 跳转(要写完整路径):

    <router-link to="/home/news">News</router-link>
    
    

     

    
    

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

posted @ 2022-12-29 21:37  安静点--  阅读(135)  评论(0)    收藏  举报