1 redirect:重定向
{
path:'/home',
name:'home',
component:()=>import('@/components/a.vue'),
redirect:'/index' //重定向
}
当访问/home时,跳转后显示的url:/index
显示的是重定向后的地址即index
2 alias:别名
{
path:'/home',
component:Home,
name:'home',
alias:"/h", //别名
}
当访问/home时,url地址还是/home,但是路由匹配/h,就像用户访问/h 一样
总结:
redirect:用户访问/home页面时,会跳转到/index页面,url会显示/index
alias:用户访问/home时,跳转到home页面,页面显示/home,同时可以使用/h访问home,页面展示/h