Vue routing parameters

Time:2021-2-25

VueRouting parameters

For the summary of routing parameters, we hope to include and correct the mistakes. recordVueTwo ways of routing parametersQuery and params

Routing parameters——-this.$route.query

< router link to = '/ home? Id = 123 & name = Zhangsan' > routing parameters query < / router link >

  • this.$route.query.id,You’ll get 123, and thisapiThere is no need to configure routing rules
  • this.$route.query.name,You can get thisapiThere is no need to configure routing rules
Routing parameters——- `this.$route.params

< router link to = / home / 123 / Zhangsan > > routing parameters params < / router link >

  • this.$route.params.id, you can’t get 123. You need to configure the routing rules as follows:{path:'/home/:id/:name',Component:home}
  • this.$route.params.nameAnd I can’t get itzhangsan, you need to configure the routing rules as follows:{path:'/home/:id/:name',Component:home}