Removing query string parameter from Url Removing query string parameter from Url vue.js vue.js

Removing query string parameter from Url


router.replace() is to navigate by removing the current URL from the browser history stack and replace it with the argument route you pass to it.

The actual syntax is router.replace(url_location, onComplete, onAbort).

What you are doing is router.replace(my_param, null) which is removing the current URL from the history stack and replacing it with 'my_param' and for the onComplete callback you are passing a null

So do it like this:

this.$router.replace('/')

More info on programatic navigation


In the case that you have multiple query parameters the correct way to remove one of them would be:

const query = Object.assign({}, this.$route.query);delete query.my_param;this.$router.replace({ query });