首页 > 其他 > 详细

vue-router-3-嵌套路由

时间:2017-10-10 11:07:39      阅读:240      评论:0      收藏:0      [点我收藏+]
<div id="app">
  <router-view></router-view>
</div>

const User = {
  template: `
    <div class="user">
      <h2>User {{ $route.params.id }}</h2>
      <router-view></router-view>
    </div>
  `
}

const router = new VueRouter({
  routes: [
    { path: /user/:id, component: User,
      children: [
        {
          // 当 /user/:id/profile 匹配成功,
          // UserProfile 会被渲染在 User 的 <router-view> 中
          path: profile,
          component: UserProfile
        },
        {
          // 当 /user/:id/posts 匹配成功
          // UserPosts 会被渲染在 User 的 <router-view> 中
          path: posts,
          component: UserPosts
        },
        // 当 /user/:id 匹配成功,设置的空路由
        // UserHome 会被渲染在 User 的 <router-view> 中
        { path: ‘‘, component: UserHome },
      ]
    }
  ]
})

 

vue-router-3-嵌套路由

原文:http://www.cnblogs.com/avidya/p/7644264.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!