I need to navigate to a specific URL:
myApp.com/search-page?name%5Bquery%5D=value
The code snippet below works perfectly when I'm on the homepage myApp.com
:
this.$router.push({
path: "search-page",
query: { name: { query: `${this.value}` } }
});
However, if I'm on a different page with a path like this:
myApp.com/movies/id
using the same code with $router.push
redirects me to this unintended URL:
myApp.com/movies/search-page?name%5Bquery%5D=value
The issue is that there is an additional movies/
segment in the URL. How can I ensure that regardless of my current path (URL), the $router.push
method always directs me to:
myApp.com/search-page?name%5Bquery%5D=value