diff --git a/examples/entry.js b/examples/entry.js index b0f3f813..8d393750 100644 --- a/examples/entry.js +++ b/examples/entry.js @@ -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 diff --git a/examples/route.config.js b/examples/route.config.js index d7301769..69d8004a 100644 --- a/examples/route.config.js +++ b/examples/route.config.js @@ -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`) };