params in Vue is used to access named parameters in the route definition (such as /user/:id's :id), while query is used to access additional parameters in the URL query string (such as /search?q= q in vue).
The difference between params and query in Vue
Foreword:
Vue. Params and query in js are two attributes used to access parameters in the URL. Both have their unique usage and differences.
params
params
Parameters are used to access named route parameters declared in the route definition. $route.params
object. query
query
Parameters are used to access parameters in the URL query string. $route.query
object. Summary of differences:
Features | params | query |
---|---|---|
Parameter source | Named parameters in route definition | Additional parameters in URL query string |
Storage location | $route.params |
$route.query |
Purpose | Pass dynamic data to components | Pass additional information to pages or components |
Access method | can be passedthis.$route.params Access |
can be accessed through this.$route.query
|
Example | #:id in ##/user/:id Parameter q## in |
/search?q=vue # Parameters
|
params.id
is 123
.
query.page
is 2
, query.sort
is asc
.
The above is the detailed content of The difference between params and query in vue. For more information, please follow other related articles on the PHP Chinese website!