R
R
Rooly2021-07-02 13:28:27
Vue.js
Rooly, 2021-07-02 13:28:27

How to redirect to the page where router.push Vue is located?

I have a functionality that just resets the project to the initial state and I need to redirect to the same page where you are

this.$router.push({name: this.$router.name, query: {}}) -- > does not work

In this case, I meant that an empty object, as it were, sets the uniqueness of the address and there will be no error
Avoided redundant navigation to current location: "/".

I didn’t find anything on the Russian-English Internet, I have no ideas how to implement such a thing (in theory, a regular redirect to the same page)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aetae, 2021-07-02
@Aetae

If you need to reset the query, then $router.replace({query: null}).
And you don't need to go to the same page. Even if you succeeded, it wouldn't do anything: the router caches the components, doesn't render from scratch.

R
rainer0, 2021-07-07
@rainer0

You can just this.$router.go(), without parameters

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question