11

I am trying to set the Query Parameters without reloading component in Vue with Vue-Router. But using below code it reloads the component:

this.$router.replace({query: this.filters});

How we can stop reload the component while changing the Query Parameters?

1
  • Can you add more context to your question, like how is your router structured. How does you router view look like, how does the component you are calling it from look like, some snippets related to these. Your issue can be caused by a number of factors, like keying on components or router-view itself etc, until then I do not think that anyone can solve your exact problem :D Commented Dec 13, 2021 at 15:29

3 Answers 3

5
this.$router.replace({ ...this.$router.currentRoute, query: this.filters });

Going to the current path will not render the currently component again

Sign up to request clarification or add additional context in comments.

1 Comment

Adding ...this.$router.currentRoute.query really works
0

According to @ManUtopiK you can use javascript's history API to accomplish this, check his answer here.

Comments

0

The following solution works for me in vue2. You can try it...

this.$router.push({name: this.$route.name, query: this.filters});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.