Sometimes, we want to set URL query params in Vue with Vue-Router.
in this article, we’ll look at how to set URL query params in Vue with Vue-Router.
How to set URL query params in Vue with Vue-Router?
To set URL query params in Vue with Vue-Router, we call router.push with an object that has the query property.
For instance, we write
router.push({ path: "register", query: { plan: "private" } });
to call router.push with an object that has the query property to add a query parameter with key plan and value private to the end of the URL with path register.
Conclusion
To set URL query params in Vue with Vue-Router, we call router.push with an object that has the query property.