2
votes

i try to delete a query parameter with a button click.

For example my route is http://localhost:8080/#/myroute?dialog=1. Now i click a button that should delete the query part ?dialog=1.

My click function look like this:

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

i have also try this attempts:

delete_query() {
  this.$router.push({ query: null });
}

delete_query() {
  this.$router.push({ name: this.$route.name });
}

But all of these functions give me the same error:

Uncaught (in promise) Error: Redirected when going from "/myroute?dialog=1" to "/myroute" via a navigation guard.

Why? What i do wrong? How can i solve this?

I have the actual version 3.5.1 of vue router installed.

1

1 Answers

0
votes

if i got it right, For delete a javascript object property you can use javascript's delete property. Like this.

    delete_query() {
 delete this.$router.query // will delete all router queries 
 delete this.$router.query.name // will delete only name property.
}