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

Solution 1:

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)
})

Solution 2:

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 {}!