I'm trying to get a Vue Router working in my Vue app. When I click the link it just reloads the page and doesn't show the Dashboard template. Any thoughts on how to fix this?
This is what I have in my main.js file:
import Vue from 'vue'
import App from './App.vue'
import VModal from 'vue-js-modal'
import TreeView from "vue-json-tree-view"
import '@/assets/css/tailwind.css'
import Vuex from 'vuex'
import VueRouter from 'vue-router'
import store from './store.js'
Vue.use(VueRouter)
Vue.use(Vuex)
Vue.config.productionTip = false
Vue.use(VModal)
Vue.use(TreeView)
let Dashboard = require('./components/Dashboard.vue');
let Home = require('./components/LandingPage.vue');
const routes = [{
path: '/',
component: Home
},
{
path: '/dasboard',
name: Dashboard,
component: Dashboard
}
];
const router = new VueRouter
({
mode: 'history',
routes
})
Vue.use(VueRouter)
new Vue({
store,
router,
render: h => h(App),
}).$mount('#app')
In my LandingPage.vue file I have this link:
<router-link to="/dashboard">Dashboard</router-link>
My Dashboard.vue file is a simple template:
<template>
<div>
<h1>Dashboard</h1>
</div>
</template>
<script>
export default {
}
</script>
<style>
</style>
Thanks