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 * */