vue2.0 路由 学习笔记

vue2.0 路由:
http://router.vuejs.org/zh-cn/index.html
基本使用:
1.  布局
主页

2. 路由具体写法,重定向{path:'*', redirect:'/home'}




    
    
    
    Document
    


    
主页 新闻


------------------------------------------
路由嵌套:
/user/username


const routes=[
   {path:'/home', component:Home},
   {
       path:'/user',
       component:User,
       children:[  //核心
           {path:'username', component:UserDetail}
       ]
   },
   {path:'*', redirect:'/home'}  //404

];




    
    
    
    Document
    


    
主页 用户

------------------------------------------

路由+参数:

/user/strive/age/10

:id
:username

:age

路由实例方法:
router.push({path:'home'});  //直接添加一个路由,表现切换路由,本质往历史记录里面添加一个
router.replace({path:'news'}) //替换路由,不会往历史记录里面添加




    
    
    
    Document
    


    
主页 用户

------------------------------------------

路由跳转配合 animate.css




    
    
    
    Document
    
    


    
主页 用户


你可能感兴趣的:(vue)