路由参数的传递与获取不再疑惑

路由传递参数一般有两种方式:

  • 在路由上添加key/value串使用,通过this.$route.query来获取
例如: :/router1?id=123 
获取: this.$router.query.id
  • 将参数作为路由一部分进行传参数,通过this.$route.params来获取
例如: /router2:id
获取:this.$route.params.id

猜你喜欢

转载自blog.csdn.net/weixin_47088026/article/details/113828368