From 39a253d476449c08dfc0206f283a8a5a165ca8a7 Mon Sep 17 00:00:00 2001 From: toesbieya <1647775459@qq.com> Date: Sat, 8 Aug 2020 01:16:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E9=A1=B5=E7=AD=BE=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/src/layout/component/TagsView/index.vue | 22 ++++++++++----------- vue/src/router/index.js | 5 ++--- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/vue/src/layout/component/TagsView/index.vue b/vue/src/layout/component/TagsView/index.vue index 9f22efd..6559342 100644 --- a/vue/src/layout/component/TagsView/index.vue +++ b/vue/src/layout/component/TagsView/index.vue @@ -81,19 +81,19 @@ export default { filterAffixTags(routes) { const tags = [] - routes.forEach(route => { - if (route.name && route.meta && route.meta.affix) { + routes.forEach(({name, fullPath, children, meta}) => { + if (meta && meta.title && meta.affix) { tags.push({ //注意,此处的fullPath并不是$route.fullPath,而是路由树拼接后的全路径 - fullPath: route.fullPath, - path: route.fullPath, - name: route.name, - meta: {...route.meta} + fullPath, + path: fullPath, + name, + meta: {...meta} }) } - if (route.children) { - const tempTags = this.filterAffixTags(route.children) - tempTags.length > 0 && tags.push(...tempTags) + if (children) { + const tempTags = this.filterAffixTags(children) + tempTags.length && tags.push(...tempTags) } }) return tags @@ -105,9 +105,9 @@ export default { } }, - //将当前具有name属性的路由添加为tab页 + //将当前具有title的路由添加为tab页 addTags(to = this.$route) { - return to.name ? this.$store.dispatch('tagsView/addView', to) : Promise.resolve() + return to.meta.title ? this.$store.dispatch('tagsView/addView', to) : Promise.resolve() }, //横向滚动条移动至当前tab diff --git a/vue/src/router/index.js b/vue/src/router/index.js index 42d1f68..422caf0 100644 --- a/vue/src/router/index.js +++ b/vue/src/router/index.js @@ -6,9 +6,8 @@ * 左侧菜单排序:能在左侧菜单中显示 && meta.sort,升序排列 * 左侧菜单不折叠只有一个children的路由:meta.alwaysShow * 面包屑显示:meta.title || meta.dynamicTitle -* 搜索选项显示:name && meta.title -* tab栏显示:name && (meta.title || meta.dynamicTitle) -* tab栏固定显示:meta.affix +* tab栏显示:meta.title || meta.dynamicTitle +* tab栏固定显示:meta.title && meta.affix * 页面不缓存:!name && !meta.usePathKey && !meta.useFullPathKey || meta.noCache * 打开iframe:meta.iframe,不会重复打开相同src的iframe * */