Skip to content

Commit

Permalink
Site: fix vue-router warn
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li authored and Leopoldthecoder committed Nov 23, 2016
1 parent 631037c commit 60701ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion examples/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions examples/route.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const registerRoute = (navConfig) => {
description: page.description,
lang
},
name: 'component',
name: 'component-' + (page.title || page.name),
component: component.default || component
};

Expand All @@ -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`)
}]
Expand All @@ -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`)
};

Expand Down

0 comments on commit 60701ad

Please sign in to comment.