Having some trouble with Vue-router - when I click on a navigation link, the desired component briefly displays before the browser tries to open it as a file.
For instance, clicking on the "Badger!" link results in the browser attempting to open a local file at
file:///home/travis/.../prototype/dist/badger
, resulting in a file not found error. Any ideas on what's going wrong? I've compared my code to existing examples but can't seem to find the issue.
main.js:
import Vue from 'vue';
import App from './App.vue';
import VueRouter from 'vue-router';
import Badger from './component/Badger.vue';
import Grid from './component/Grid.vue';
Vue.use(VueRouter);
const router = new VueRouter({
mode: 'history',
base: __dirname,
routes: [
{ path: '/badger', component: Badger },
{ path: '/grid', component: Grid },
]
});
new Vue({
el: '#app',
router,
render: h => h(App),
});
App.vue
<template>
<div id="app">
<ul>
<li>
<router-link to="/badger">Badger!</router-link>
</li>
<li>
<router-link to="/grid">Data!</router-link>
</li>
</ul>
<router-view></router-view>
</div>
</template>
<script>
export default {
mounted() {
console.log('mounted App component')
},
data() {
// ...
}
},
}
</script>
<style>
// ...
</style>