Smit Patel
Smit Patel

Reputation: 177

How to set query parameters without reloading component in Vue with Vue-Router

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?

Upvotes: 10

Views: 4735

Answers (3)

MD Golam Rakib
MD Golam Rakib

Reputation: 144

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

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

Upvotes: 0

Pedrocate
Pedrocate

Reputation: 144

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

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

Upvotes: 4

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

Upvotes: 0

Related Questions