//创建路由对象并配置路由规则
let router = new VueRouter({ routes:[ {path:'/',redirect:{name:"index"}}, // 重定向到主页 {name:'index',path:'/index',component:Index}, {path:'/login',component:Login}, {path:'/register',component:Register}, {path:'*',component:Index},//全不匹配的情况下,返回到主页,路由按顺序从上到下,依次匹配。最后一个*能匹配全部, ] });