baseui/src/main.js

62 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-08-24 11:16:07 +02:00
import Vue from 'vue';
import Vuex from 'vuex';
import VueRouter from 'vue-router';
2017-08-24 13:23:03 +02:00
import Axios from 'axios';
import App from './app.vue';
2017-08-24 11:16:07 +02:00
import Dashboard from './components/dashboard.vue';
import Userlist from './components/userlist.vue';
Vue.use(VueRouter);
2017-08-24 13:23:03 +02:00
Vue.use(Vuex);
2017-08-24 11:16:07 +02:00
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: {
2017-08-24 13:23:03 +02:00
App
2017-08-24 11:16:07 +02:00
},
data: {
2017-08-24 13:23:03 +02:00
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);
});
2017-08-24 11:16:07 +02:00
}
});