How to use the vue-router.createRouter function in vue-router

To help you get started, we’ve selected a few vue-router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facette / facette / ui / src / router.ts View on Github external
import admin from "@/views/admin";
import dashboards from "@/views/dashboards";

const routes = Array().concat(
    {
        path: "/",
        name: "root",
        redirect: {
            name: "dashboards-home",
        },
    },
    ...admin,
    ...dashboards,
);

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes,
    linkActiveClass: "",
    linkExactActiveClass: "active",
});

export default router;

router.beforeEach((to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => {
    // Each time route is changing, store previous route location and reset
    // error from store.
    if (from.name && to.name !== from.name && !isEqual(to.params, from.params)) {
        store.commit("prevRoute", from);
    }

    store.commit("error", null);
github TwinProduction / gatus / web / app / src / router / index.js View on Github external
import Details from "@/views/Details";

const routes = [
	{
		path: '/',
		name: 'Home',
		component: Home
	},
	{
		path: '/services/:key',
		name: 'Details',
		component: Details,
	},
]

const router = createRouter({
	history: createWebHistory(process.env.BASE_URL),
	routes
})

export default router
github omohokcoj / motor-admin / ui / src / router.js View on Github external
component: FormsShow,
    name: 'form'
  },
  {
    path: '/forms',
    component: FormsIndex,
    name: 'forms'
  },
  {
    path: '/reports/:type?',
    component: ReportsIndex,
    name: 'reports'
  }
]

const router = createRouter({
  history: createWebHistory(basePath),
  parseQuery: qs.parse,
  stringifyQuery: qs.stringify,
  routes
})

export default router
github nanu-c / axolotl / axolotl-web / src / router / router.js View on Github external
import { createRouter, createWebHistory } from 'vue-router'
import store from '../store/store'



export const router = new createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: "/",
      alias: "/chatList",
      name: "chatList",
      component: () => import("@/pages/ChatList.vue")
    },
    {
      path: "/chat/:id",
      name: "chat",
      props: route => ({
        chatId: Number(route.params.id),
      }),
      component: () => import("@/pages/MessageList.vue")
    },