Vue Js Redirect to Another Page
Vue Js Redirect from one page to another page in Vue Router : In VueJS, a route redirect is when a user requests a certain URL and the server sends back an HTTP status code that tells the browser to replace that requested page with another one .This can be accomplished by using the `redirect` function within the route configuration, which takes two parameters: the URL to be redirected from, and the URL to which it will redirect.In this tutorial, we will learn how to redirect from one page to another in Vue Router.




Thanks for your feedback!
Your contributions will help us to improve service.
How to redirect from one page to another page in Vue Router?
Routes configuration allows a URL to be redirected to another location, either internally on the server or externally. Here below are some example redirect routes from base (/) to the administrative page (/admin) providing an easy way to access the administrative page of a website or application
Vue Js 4.0: To redirect from base url (/)to admin page(/admin)
xxxxxxxxxx
const routes = [{
path: '/',
redirect: '/admin'
}]
Vue Js 3.0 Version: Redirect to Another Page
xxxxxxxxxx
const router = new VueRouter({
routes: [
{ path: '/', redirect: '/admin' }
]
})
How can a redirect target a named route?
This also provides a convenient way to create links to named routes without having to manually specify the full route and action for each link
Vue Js 4.0 version: Redirect to another page as a named route
xxxxxxxxxx
const routes = [{
path: '/',
redirect: { name: 'admin' }
}]
Vue Js 3.0 version: Redirect to another page as a named route
xxxxxxxxxx
const router = new VueRouter({
routes: [
{ path: '/',
redirect: { name: 'admin' }}
]
})