0👍
Possible reasons are
- You didn’t import router properly in your code
- You don’t
Vue.use(VueRouter)
, just pass it to your new Vue object parameters
Correct it like so
import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'router'
import Home from './components/Home'
import Contact from '././components/Contact'
Vue.config.productionTip = false
const Bar = { template: '<div>bar</div>' }
const routers = [
{ path: '/', component: Bar },
];
let router = new VueRouter({mode: 'history', routes: routers});
new Vue({
router
}).$mount('#app')
it should work if your App.vue (imported on line 2) has <router-view />
component in its template and all other imports are valid.
Source:stackexchange.com