Use vue.router for redirecting to absolute path

Viewed 3756

All of the examples that I can find help to manage routes inside the application like this

this.$router.push({name: RouteName})

what if I want to make redirection by absolute path? I tries

this.$router.push({fullPath: https://google.com})

But it does nothing

1 Answers

vue-router is designed for routing within your app. It makes no sense to use it to redirect to external sites.

You can still use vue-router like this:

this.$router.push({ redirect: window.location.href = 'https://google.com' });

But it'll be better to use vanilla js:

window.location.href = 'https://google.com';
Related