query:
path+query搭配使用;
页面刷新时,传递过来的参数不会消失;
传递过去的参数会在url显示;
this.$router.push({
path:'aaa/index2',
query:{id:10086,name:'zhangsan'}
})
this.$route.query.id
params:
name+params搭配使用;
页面刷新时,传递过来的参数会消失;
传递过去的参数在url上可以显示也可不显示;
《配置路由的地方》:
path:‘aaa/index’ 参数不显示
path:'aaa/index/:id/:name' (属性名要对应) 参数显示
this.$router.push({
name:'idnex2'
params:{id:10086,name:'zhangsan'}
})
this.$route.params.id