Vue Router 4–Redirects. In this article, we’ll look at how to use Vue Router 4 with Vue 3. Redirect. We can add redirects to our routes. For example, we can write. We can also redirect with a callback method. We can redirect our routes in various ways with VueRouter.
Vue Router 4 is in beta and it’s subject to change.
To build a single page app easily, we got to add routing so that URLs will be mapped to components that are rendered.
In this article, we’ll look at how to use Vue Router 4 with Vue 3.
We can add redirects to our routes.
For example, we can write:
<!DOCTYPE html> <html lang="en"> <head> <script src="https://unpkg.com/[email protected]"></script> <script src="https://unpkg.com/[email protected]/dist/vue-router.global.js"></script> <title>App</title> </head> <body> <div id="app"> <p> <router-link to="/foo">foo</router-link> <router-link to="/bar">bar</router-link> <router-link to="/baz">baz</router-link> </p>