重定向和别名

new router({

  routes:[

    {

      path: '/',

      conponent: home,

      name: 'Home',

      alias: '/index'

    },{

      path: '/about',

      conponent: about,

      name: 'About', 

    },{

      path: '/document',

      conponent: document,

      name: 'Document', 

    },{

      path: '*',

      // redirect: home  组件方式重定向

      // redirect: 'Home'   别名方式重定向

      // redirect: '/'

      //redirect (to) =>{
        if(to.path==='/123'){

          to.path='/'

         }else{

          to.path='/about'

          }
      }  

    },

  ]

})

posted @ 2017-07-29 00:56  啊友的前端历程  阅读(446)  评论(0编辑  收藏  举报