Is there a way to do a redirect? #63
-
|
with vue router I have this to auto redirect to the dashboard page whenever the '/' route is visited. Is there a way to do this with this plugin using filenames or would I just have to have an |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
Use extendRoutes to add the redirect option: const router = createRouter({
extendRoutes: (routes) => {
const targetRoute = routes.find((r) => r.name === '/')
if (targetRoute) {
targetRoute.redirect = { name: 'dashboard' }
}
// completely optional since we are modifying the routes in place
return routes
},
history: createWebHistory(),
})Since the |
Beta Was this translation helpful? Give feedback.
-
|
Is there an update to this with newer versions? |
Beta Was this translation helpful? Give feedback.
Use extendRoutes to add the redirect option:
Since the
redirectoption only exist for routes without acomponentor withchildren, it's a different type of option. Maybe we could find a way of improving this. The problem when addingredirectto the<route block>is that it still forces to add other options if the route doesn't have children 🤔