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

后端 未结 5 2092
醉酒成梦
醉酒成梦 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:30

    Adding to this, if you are putting the routes in the same page instead of importing it, It must be declared before the Vue component render.

    Like this:-

    const router = new VueRouter({
      mode: 'history',
      routes:[
        { path: '/dashboard', component: Dashboard},
        { path: '/signin', component: Signin}
      ]
    });
    
    new Vue({
      el: '#app',
      router,
      render: h => h(App)
    })
    

    Not like this :

    new Vue({
      el: '#app',
      router,
      render: h => h(App)
    })
    
    const router = new VueRouter({
      mode: 'history',
      routes:[
        { path: '/dashboard', component: Dashboard},
        { path: '/signin', component: Signin}
      ]
    });
    

提交回复
热议问题