I suggest to add a new function useRouteQueries
to @vueuse/router
add-on.
#4941
Closed
bestcb2333
started this conversation in
Ideas
Replies: 1 comment
-
I think it's unnecessary and can be solved by |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I suggest to add a new function
useRouteQueries
to@vueuse/router
add-on. The usage ofuseRouteQueries
is similar but different to the existinguseRouteQuery
function in@vueuse/router
.For example, In useRouteQuery:
It will be more convenient if we use
useRouteQueries
that I suggested:The relation between
useRouteQuery
anduseRouteQueries
is similar to the relation betweenref
andreactive
.The features in
useRouteQueries
is: It will only use the query params that the object passed to useRouteQueries defined. And it's type safe, it can infer the return value type ofuseRouteQueries
via the object passed touseRouteQueries
. And the values in the object passed touseRouteQueries
is the default value. If the type of current route query param is different to the type that the object defined, the will use the default value, such as/users?ageGt=five
will beageGt=0
inuseRouteQueries({ ageGt: 0 })
.Beta Was this translation helpful? Give feedback.
All reactions