Skip to content

Commit 5b88067

Browse files
committed
fix: multi-tab mode always component keep-alive & cleanup eslint
Signed-off-by: Sendya <[email protected]>
1 parent 9d00ebb commit 5b88067

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/components/MultiTab/MultiTab.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default {
3838
}
3939
this.pages = this.pages.filter(page => page.fullPath !== targetKey)
4040
this.fullPathList = this.fullPathList.filter(path => path !== targetKey)
41-
},
41+
}
4242
},
4343
watch: {
4444
'$route': function (newVal) {
@@ -53,4 +53,4 @@ export default {
5353
}
5454
}
5555
}
56-
</script>
56+
</script>

src/components/MultiTab/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import MultiTab from './MultiTab'
2-
export default MultiTab
2+
export default MultiTab

src/components/layouts/RouteView.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
return {}
66
},
77
render () {
8-
const { $route: { meta } } = this
8+
const { $route: { meta }, $store: { getters } } = this
99
1010
const inKeep = (
1111
<keep-alive>
@@ -15,7 +15,10 @@ export default {
1515
const notKeep = (
1616
<router-view />
1717
)
18-
return meta.keepAlive ? inKeep : notKeep
18+
// 这里增加了 multiTab 的判断,当开启了 multiTab 时
19+
// 应当全部组件皆缓存,否则会导致切换页面后页面还原成原始状态
20+
// 若确实不需要,可改为 return meta.keepAlive ? inKeep : notKeep
21+
return meta.keepAlive || getters.multiTab ? inKeep : notKeep
1922
}
2023
}
21-
</script>
24+
</script>

0 commit comments

Comments
 (0)