Site: fix vue-router warn

This commit is contained in:
qingwei.li 2016-11-22 10:22:20 +08:00 committed by 杨奕
parent 631037c296
commit 60701ad408
2 changed files with 13 additions and 6 deletions

View File

@ -26,7 +26,14 @@ const router = new VueRouter({
});
router.afterEach(route => {
document.title = title[route.meta.lang][route.name] || 'Element';
const data = title[route.meta.lang];
for (let val in data) {
if (new RegExp('^' + val, 'g').test(route.name)) {
document.title = data[val];
return;
}
}
document.title = 'Element';
});
new Vue({ // eslint-disable-line

View File

@ -38,7 +38,7 @@ const registerRoute = (navConfig) => {
description: page.description,
lang
},
name: 'component',
name: 'component-' + (page.title || page.name),
component: component.default || component
};
@ -57,12 +57,12 @@ const generateMiscRoutes = function(lang) {
component: require(`./pages/${ lang }/guide.vue`),
children: [{
path: 'design', // 设计原则
name: 'guide',
name: 'guide-design' + lang,
meta: { lang },
component: require(`./pages/${ lang }/design.vue`)
}, {
path: 'nav', // 导航
name: 'guide',
name: 'guide-nav' + lang,
meta: { lang },
component: require(`./pages/${ lang }/nav.vue`)
}]
@ -71,14 +71,14 @@ const generateMiscRoutes = function(lang) {
let resourceRoute = {
path: `/${ lang }/resource`, // 资源
meta: { lang },
name: 'resource',
name: 'resource' + lang,
component: require(`./pages/${ lang }/resource.vue`)
};
let indexRoute = {
path: `/${ lang }`, // 首页
meta: { lang },
name: 'home',
name: 'home' + lang,
component: require(`./pages/${ lang }/index.vue`)
};