I'm switching from routing with Laravel to using Vue-Router on my application, and I can only get the base route to load using Vue-Router. I've seperated the routes into two files, public and private using the example from this article: https://itnext.io/vue-router-99e334094362. I'm new to Vue-Router, what am I doing wrong?
Here's my code:
main.blade.php
:
<div id="app">
<section>
<!-- header menu -->
<am-app-nav></am-app-nav>
</section>
<section>
<router-view></router-view>
</section>
<section>
<!-- Footer -->
<am-footer></am-footer>
</section>
</div>
app.js
:
window.Vue = require('vue')
import Vue from 'vue'
import VueRouter from 'vue-router'
import router from './router/index.js'
Vue.use(VueRouter)
const app = new Vue({
el: '#app',
router,
})
router/index.js
:
import Vue from 'vue'
import Router from 'vue-router'
import routes from './routes/index.js'
Vue.use(Router)
const router = new Router({
mode: 'history',
routes: [
{
path: '/',
redirect: '/welcome',
},
].concat(routes),
})
export default router
router/routes/index/js
:
import publicRoutes from './public.js'
import privateRoutes from './private.js'
export default publicRoutes.concat(privateRoutes)
router/routes/private.js
:
const routes = [
{
path: '/dashboard',
component: require('../../views/admin/Dashboard').default,
},
{
path: '/client-details',
component: require('../../views/admin/ClientDetails').default,
},
{
path: '*', component: require('../../views/public/NotFound').default
},
]
export default routes.map((route) => {
return { ...route, meta: { public: false } }
})