Vue front-end interview summary (29) How to implement Vue routing parameters in detail

Vue routing parameters

Routing parameters are divided into two types of
query and params to achieve

How to implement parameter passing in query

Pass in router-link or this.$router.push()
Pass splicing in the address bar? Passed parameters

Then use this.$route.quey.id () to receive it on the page.
Advantages: better versatility, refreshing the data will not disappear

How to realize parameter transfer in Params

It is also passed in router-link or this.$router.push()
in the address bar to use / for splicing. For
example, router-link to = "/goods?id=000"

Then receive it on the page through this.$route.params.id
Advantages: The amount of refreshed data is at the same level.
Disadvantages: The refreshed data will not disappear.

Guess you like

Origin blog.csdn.net/Rick_and_mode/article/details/108653053