import Vue from 'vue'; import Vuex from 'vuex'; import VueRouter from 'vue-router'; import Axios from 'axios'; import App from './app.vue'; import Dashboard from './components/dashboard.vue'; import Userlist from './components/userlist.vue'; Vue.use(VueRouter); Vue.use(Vuex); const store = new Vuex.Store({ state: { }, mutations: { } }) const routes = [ { path: '/', component: Dashboard }, { path: '/userlist', component: Userlist } ]; const router = new VueRouter({ routes }); new Vue({ el: '#vue-app', components: { App }, data: { navItems: [ ] }, router, store, created() { // load init Axios.get('conf/init.json') .then(results => { if ( !Array.isArray(results.data.navigation) ) { alert('invalid data in: ' + this.src); return; } // add routes this.navItems = results.data.navigation; }) .catch(error => { alert('error loading ' + this.src + ': ' + error.message); }); } });