title meta

This commit is contained in:
Sebastian Frank
2017-08-29 16:34:24 +02:00
parent 7584f78947
commit 2220bce227
3 changed files with 14 additions and 5 deletions

View File

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

View File

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

View File

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