vue 路由问题

路由跳转:

  {

    name:user,

    path: '/user/:id',

    components: user

  }

  1.this.$router.push('/user') => 可以带在路由已经定义的参数 => this.$router.push('/user/id'+id)

  2.this.$router.push({name: routerName(路由名字),params:{这里面可以带各种参数,但是页面刷新会清空,除了在路由页面已经定义的参数}) =>  this.$router.push({name:user,params:{id: '',age:18})

路由守卫:router.beforeEach((to, from, next) => { // ... }) => 可以用来判断token是否超时,是否已经登陆

  to() => 跳转的路由(下一个路由)

  from() => 当前路由

  next() => 必须调用这个钩子才可以进入下个路由

posted @ 2018-03-16 16:10  会醉的鸟  阅读(118)  评论(0编辑  收藏  举报