[Vuejs]-How can I transmit from a component to another when redirecting in VueJS?

0👍

Out of 3 console.logs, only the first one (this.$router.params) actually shows up

That’s most likely because your component has been unmounted after route change. That’s why watchers don’t work anymore.

About the first console.log, if you redirected here from the first component with:

this.$router.replace({ name: 'login', params: { error: 'not_logged' } })

Then I think $route.params should have this param (not $router.params).

Also you can declare props on component and pass them from route definition as described here: https://router.vuejs.org/guide/essentials/passing-props.html#boolean-mode

Notice:

When props is set to true, the route.params will be set as the component props.

Leave a comment