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 @   安静点--  阅读(124)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
点击右上角即可分享
微信分享提示