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

后端 未结 5 2093
醉酒成梦
醉酒成梦 2020-12-28 15:45

I\'m trying to write my first Vuejs app. I\'m using vue-cli and simple-webpack boilerplate.

When I add vue-router links to my app component

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 16:08

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

提交回复
热议问题