title meta

This commit is contained in:
Sebastian Frank 2017-08-29 16:34:24 +02:00
parent 7584f78947
commit 2220bce227
No known key found for this signature in database
GPG Key ID: DC2BC5C506EBF6F3
3 changed files with 14 additions and 5 deletions

@ -1,4 +1,5 @@
{
"title": "MyApp",
"api": {
"baseURL": "https://cx20.basehosts.de/api/v1/"
},

@ -2,7 +2,6 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vue Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.component-fade-enter-active, .component-fade-leave-active {

@ -179,7 +179,7 @@ Axios.get('conf/init.json')
}
let navigation = [];
results.data.navigation.forEach(({name, to}) => navigation.push({name, to}));
store.commit("setNavigation", navigation);
// set api config in store
@ -188,10 +188,14 @@ Axios.get('conf/init.json')
// add routes
let routes = [];
let rIdx = 0;
results.data.navigation.forEach(({to, content, data}) => routes.push({
results.data.navigation.forEach(({name, to, content, data}) => routes.push({
name: name,
path: to,
component: Vue.component('main' + rIdx++, {
template: '<div id="main'+ rIdx + '">' + content + '</div>',
meta: {
title: name
},
component: Vue.component(name + rIdx++, {
template: '<div id="' + name + rIdx + '">' + content + '</div>',
components: Views,
data() {
if (typeof data != 'object') {
@ -202,6 +206,11 @@ Axios.get('conf/init.json')
})
}));
router.addRoutes(routes);
router.beforeEach((to, from, next) => {
console.log(to);
document.title = (to.meta && to.meta.title) ? results.data.title + ': ' + to.meta.title : results.data.title;
next();
});
// load app, when init finishs
new Vue({