{{message}}
let login={
template:'
登陆组件{{$route.query.id}}
',created(){//组件的生命周期钩子函数
console.log(this.$route);
console.log(this.$route.query.id);
}
}
let register={
template:'
注册组件{{$route.params.name}}
'}
let routerObj=new VueRouter({
routes:[
{path:"/",redirect:'/login'},
{path:'/login',component:login},
{path:'/register/:name',component:register}
],
linkActiveClass:'myactive'
});
let app=new Vue({
el:'#app',
data:{
message:'Hello World'
},
router:routerObj
})