2
respostas

Após alterar o import aos componentes no meu arquivo de rotas, obtive o seguinte erro: Error: [vue-router] "path" is required in a route configuration.

/** ** **
 ** Libs
 ** ** **/
import Vue from 'vue';
import VueRouter from 'vue-router';
import auth from '../services/OAuthService';

/** ** **
 ** Components
 ** ** * */
import Home from '../components/Home.vue';

import Login from './Login';

/** ** **
 ** Routes
 ** ** * */
const Dashboard = () => System.import('./dashboard/router');
const Deals = () => System.import('./deals/deals');
const Tasks = () => System.import('./tasks');
const WorkSchedule = () => System.import('./workSchedule');
const Contacts = () => System.import('./contacts');
const Plannings = () => System.import('./planning/plannings');
const Meetings = () => System.import('./meetings');
const Swot = () => System.import('./planning/swot');
const Vision = () => System.import('./planning/vision');
const Projects = () => System.import('./projects');
const Settings = () => System.import('./settings');
const Customers = () => System.import('./customers/customers');
const Products = () => System.import('./products');
const Timesheets = () => System.import('./timesheets');
// const Login = () => System.import('./login');
const PlanTree = () => System.import('./planning/plantree');
const Tickers = () => System.import('./tickets/tickets');
const Scorecard = () => System.import('./scorecard');
const Kanban = () => System.import('./kanban');
const Reports = () => System.import('./reports');
const mycalendar = () => System.import('./mycalendar');
const Kpi = () => System.import('./kpi');
const KpiDataEntry = () => System.import('./kpidataentry');
const LicenseControl = () => System.import('./licensecontrol');
const ProductLicense = () => System.import('./productlicense');

const routes = [{
    path: '*',
    redirect: '/',
    component: App,
    meta: {
      requireAuth: true,
    },
  },
  {
    path: '/',
    component: Home,
    meta: {
      requireAuth: true,
    },
  },
  Dashboard,
  Deals,
  Tasks,
  Contacts,
  Plannings,
  Projects,
  Settings,
  Customers,
  Products,
  Timesheets,
  Swot,
  Vision,
  Tickers,
  PlanTree,
  Login,
  Meetings,
  Scorecard,
  Kanban,
  Reports,
  mycalendar,
  Kpi,
  KpiDataEntry,
  WorkSchedule,
  LicenseControl,
  ProductLicense,
];

/** ** **
 ** Uses
 ** ** **/
Vue.use(VueRouter);

/** ** **
 ** Main Export
 ** ** * */
const router = new VueRouter({
  // mode: 'history',
  linkActiveClass: 'active-link',
  routes,
});

router.beforeEach((to, from, next) => {
  if (!auth.isAccessTokenValid()) {
    if (!to.meta.isLogin) {
      auth.getNewAccessToken().then(
        sucess => {
          next();
        },
        error => {
          next('/login');
        },
      );
    } else {
      next();
    }
  } else {
    next();
  }
});

export default router;
2 respostas

Transferi os códigos que estavam contidos em outros arquivos que possuíam o conteúdo das rotas para dentro deste arquivo e deu certo.

Fala Italo, posta aqui como ficou para que outros alunos tenham a solução :D

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software