Vue-router: Cannot read property 'matched' of undefined && Unknown element <router-link> && Unknown element <router-view>

Created on 21 Sep 2016  路  15Comments  路  Source: vuejs/vue-router

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

`

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

Most helpful comment

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.

All 15 comments

My bad... Just missed it...

Hello @MartianGreed, I'm having the same error message in here. Did you solved by using that alias sugested by @yyx990803 ?

This is not working to me. Any way, I don't understand why I need to use the standard lib if I'm using webpack to pre-compile my templates... this part of documents is TOO vague.

I really can't tell you because i'm no expert of VueJs... The solution @yyx990803 proposed worked well for me!

Ok, thanks for your reply any way.... I'll keep trying in here!

For my and future people's sake: What did @yyx990803 's link refer to? It seems like it's not on the page anymore...

The link is now at
https://vuejs.org/v2/guide/installation.html#Standalone-vs-Runtime-only-Build

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.

I'm having the same issue here. Resolver is in place.

Same here, but using browserify with

"browser": {
    "vue": "vue/dist/vue.common"
  },

in my package.json

I gave up on vue router and went with page. So complicated for what it is.

@cyberdude the official webpack template has vue-router working out of the box...

I'll check it out. The issue for me is vue-loader and vue-router playing nice together. I wanna use .vue files and not hard coded html templates. They hate each other at the time.

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.

@zzzgit Please, use the forums to ask questions

Was this page helpful?
0 / 5 - 0 ratings