How to set URL query params in Vue with Vue | vue push query
Hereistheexampleindocs://withquery,resultingin/register?plan=privaterouter.push({path:register,query:{plan:private}})Ref:https://router.vuejs.org/en/essentials/navigation.html[1]Asmentionedinthosedocs,router.replaceworkslikerouter.pushSo,youseemtohaveitrightinyoursamplecodeinquestion.ButIthinkyoumayneedtoincludeeithernameorpathparameteralso,sothattherouterhassomeroutetonavigateto.Withoutanameorpath,itdoesnotlookverymeaningful.Thisismycurrentunderstandingnow:queryisoptionalforrouter-someaddit...
Here is the example in docs:
// with query, resulting in /register?plan=private router.push({ path: register, query: { plan: private }})Ref: https://router.vuejs.org/en/essentials/navigation.html[1]
As mentioned in those docs, router.replace works like router.push
So, you seem to have it right in your sample code in question. But I think you may need to include either name or path parameter also, so that the router has some route to navigate to. Without a name or path, it does not look very meaningful.
This is my current understanding now:
query is optional for router - some additional info for the component to construct the view name or path is mandatory - it decides what component to show in your <router-view>.That might be the missing thing in your sample code.
EDIT: Additional details after comments
Have you tried using named routes in this case? You have dynamic routes, and it is easier to provide params and que...