传参: this.$router.push({ path:'/xxx', query:{ id:id } }) 接收参数: this.$route.query.id
注意:传参是this.$router,接收参数是this.$route,这里千万要看清了!!!
this.$router 和this.$route有何区别?
在控制台打印二者能够很明显的看出二者的一些区别:vue
传参: this.$router.push({ name:'xxx', params:{ id:id } }) 接收参数: this.$route.params.id
注意:params传参,push里面只能是 name:'xxxx',不能是path:'/xxx',由于params只能用name来引入路由,若是这里写成了path,接收参数页面会是undefined!!!
vue-router
vue的自学之路还得继续走,坑还会继续踩,下一个坑会是神马...post