Vue-router error: TypeError: Cannot read property 'matched' of undefined

On my Vue file I had the following code:

Then, I modified my app.js file, and place the following code:

import router from './Router/router.js'

const app = new Vue({
    el: '#app',
    router
});

vue & vue router & match bug & solution

match bugs

image

image

solution

name must be router

https://stackoverflow.com/a/44618867/5934465

image

OK

image

image


import default module bug

import default module no need {}!


The name when you add it to Vue must be router.

import router from './routes.js'

const app = new Vue({
  el: '#app',
  router,
  render: h => h(App)
})

If, for whatever reason, you want to call the variable routes you could assign it this way.

import routes from './routes.js'

const app = new Vue({
  el: '#app',
  router: routes,
  render: h => h(App)
})