[Vuejs]-In Vuejs, remove the object values in URL after passing object in router query?

0👍

You can use history.replaceState() to change the URL without navigating. Place this in the created hook of the page you’re loading:

created() {
    history.replaceState(history.state, "", "/staffProfile");
}

downsides include losing the query params if you manually reload the page or while manually navigating back to the previous page then forward. Only when clicking your button will the page load with the query params intact. If you need an alternative solution that always preserves this data, you might want to look into saving the query params using a state management library (Vuex or Pinia), or the browser’s localStorage API

Leave a comment