美文网首页
scotch vue-shop (2) 路由

scotch vue-shop (2) 路由

作者: 邱杉的博客 | 来源:发表于2017-10-23 20:01 被阅读0次
export default new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home,
    },
    {
      path: '/admin',
      name: 'Admin',
      component: Admin,
    },
    {
      path: '/cart',
      name: 'Cart',
      component: Cart,
    }
  ]
});

name 字段有用吗,这里只是为了起个名字表示一下,还有有功能上实际的用途?

Route Links

Rather than the a tag, we use Vue's router-link component. router-link is just a wrapper for the a tag with some optimization logic.

路由对象

  • $route.path
    字符串,等于当前路由对象的路径,会被解析为绝对路径,如 "/home/news"
  • $route.params
    对象,包含路由中的动态片段和全匹配片段的键值对
  • $route.query
    对象,包含路由中查询参数的键值对。例如,对于 /home/news/detail/01?favorite=yes ,会得到 $route.query.favorite == 'yes'
  • $route.router
    路由规则所属的路由器(以及其所属的组件)
  • $route.matched
    数组,包含当前匹配的路径中所包含的所有片段所对应的配置参数对象
  • $route.name
    当前路径的名字,如果没有使用具名路径,则名字为空

相关文章

网友评论

      本文标题:scotch vue-shop (2) 路由

      本文链接:https://www.haomeiwen.com/subject/mytzuxtx.html