Saya memiliki file router.js utama di mana saya ingin menggunakan file lain dengan rute - routeManagement.

Router.js:

import routesManagement from './routesManagement'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Dashboard',
    component: Dashboard
  },
  
  routesManagement,
]
export default router

RouteManagement.js:

import Tools from '../../views/management/Tools.vue'

const routeManagement = [
    {
        path: '/tools',
        name: 'Tools',
        component: Tools
    },
]
export default routeManagement

Ketika saya melakukan ini, aplikasi berhenti bekerja dan saya mendapatkan kesalahan:

Uncaught Error: [vue-router] "path" is required in a route configuration.

Bagaimana memperbaikinya? Apa yang saya lakukan salah?

0
Weronika 12 Mei 2021, 13:38

1 menjawab

Jawaban Terbaik

Destruktur larik routesManagement:

const routes = [
  {
    path: '/',
    name: 'Dashboard',
    component: Dashboard
  },
  
  ...routesManagement,
]
2
Ohgodwhy 12 Mei 2021, 10:38