title meta
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"title": "MyApp",
|
||||||
"api": {
|
"api": {
|
||||||
"baseURL": "https://cx20.basehosts.de/api/v1/"
|
"baseURL": "https://cx20.basehosts.de/api/v1/"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
17
src/main.js
17
src/main.js
@@ -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({
|
||||||
|
|||||||
Reference in New Issue
Block a user