Redirect vue route
Devmnj • Sat Jun 19 2021
0 min read
Sometimes we would like to have same route with different name, such guide to FAQ, help, how-to etc. Vue allow us to use the redirect feature for this purpose.
Redirect can be used in our index route file in the following format
Source code
import Vue from "vue";
......
Vue.use(VueRouter);
const routes = \[
{
path: "/",
name: "Line",
component: LineChart,
},
{
// The redirect can also be targeting a named route:
path: "/help",
redirect: { name: 'About' }
}
\];
const router = new VueRouter({
routes
});
export default router;
In the above router configuration we redirect /help router to the named route /About. For multiple route we have to reply on alias.