import Vue from 'vue'; import VueRouter, { RouteConfig } from 'vue-router'; Vue.use(VueRouter); export const components = [ { path: '/icon', label: 'Icon' }, { path: '/filter', label: 'Filter' }, ]; const routerComponents = components.map((item: any) => ({ path: `${item.path}`, name: `${item.label}`, component: () => import(`@/views${item.path}/index.vue`), })); export const routes: Array = [ { path: '/', name: 'Root', redirect: components[1].path, }, ...routerComponents, ]; const router = new VueRouter({ mode: 'history', base: '/', routes, }); export default router;