Unknown element: <router-view> - did you register the component correctly? In Vue-Router

I have an issue I looked everywhere but not found suitable solution.

[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> at src/App.vue

import Vue from 'vue'
import App from './App.vue'
import Generic from './Generic.vue' import ABC from './abc.vue' import  ueRouter from 'vue-router' import { routes } from './router.js'
Vue.component('vue-header', Header); Vue.component('vue-generic', eneric); Vue.component('vue-abc', ABC);
Vue.use('VueRouter');

const router = new VueRouter({
routes,
  mode: 'history'
});
new Vue({  el: '#app',  routes,  render: h => h(App) })

Thanks in advance

1 answer

  • answered 2018-04-14 17:14 acdcjunior

    Don't call Vue.use() on a string. So, instead of having Vue.use('VueRouter') as in:

    import VueRouter from 'vue-router';
    Vue.use('VueRouter'); // don't call .use() on a string
    

    Call Vue.use() on the previously imported reference (e.g. Vue.use(VueRouter)) as in:

    import VueRouter from 'vue-router';
    Vue.use(VueRouter); // call .use() on the imported reference