vue-router: Cannot read property 'matched' of undefined && Unknown element && Unknown element

Hey,

i got those weird issues with this setup:

  • “vue”: “^2.0.0-rc.6”,

  • “vue-router”: “^2.0.0-rc.5”

  • main.js

    import Vue from ‘vue/dist/vue’ import App from ‘./App.vue’

    import router from ‘./router/index’

    new Vue({ router, …App }).$mount(‘#root’)

  • router.js

    import VueRouter from ‘vue-router’ import Vue from ‘vue/dist/vue’

    Vue.use(VueRouter)

    import App from ‘…/App’ import LoginApp from ‘…/components/login/LoginApp’

    const routes = [ { path: ‘’, component: App }, { path: ‘/login’, component: LoginApp } ]

    export default new VueRouter({ mode: ‘history’, base: ‘/’, scrollBehavior: () => ({ y: 0 }), routes: routes

    })`

  • App.vue

    <template> <div id="app"> <router-link to="/">Home</router-link> <router-link to="/login">Login</router-link> <router-view></router-view> </div>

    </template>`

I just can’t figure out what’s wrong… Tried to find examples, googled the errors but i just found nothing… I inspired myself of this : Vue Hackernews 2.0

The “Vue Warn” for router-view and router-links can be resolved by writing them in template instanciation of Vue in main.js. I wonder why is there the warn outside this file.

And I got the error cannot read ‘matched’ of undefined that i just don’t understand…

Did you guys know what’s wrong ?? Cheers

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I’m having the exact same issue with routes failing on ‘matched’ error. But I used the vue-cli webpack which already has this resolver in place.

image

image

No such a file in node_modules. I have got the same problem.the official demos use in-line template and $mount,but I use .vue file,and this error I got.