|
1
|
<template>
|
|
2
|
<div class="main">
|
|
3
|
<keep-alive :include="includedComponents">
|
|
4
|
<router-view v-if="keepAlive" />
|
|
5
|
</keep-alive>
|
|
6
7
|
<router-view v-if="!keepAlive" />
</div>
|
|
8
9
10
|
</template>
<script>
|
|
11
12
13
|
import Vue from 'vue'
import { CACHE_INCLUDED_ROUTES } from "@/store/mutation-types"
|
|
14
15
16
|
export default {
name: "RouteView",
computed: {
|
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
//update-begin--Author:scott Date:20201015 for:路由缓存问题,关闭了tab页时再打开就不刷新 #842
includedComponents() {
const includedRouters = Vue.ls.get(CACHE_INCLUDED_ROUTES)
console.log("includedRouters:" + includedRouters)
//如果是缓存路由,则加入到 cache_included_routes
if (this.$route.meta.keepAlive && this.$route.meta.componentName) {
let cacheRouterArray = Vue.ls.get(CACHE_INCLUDED_ROUTES) || []
if(!cacheRouterArray.includes(this.$route.meta.componentName)){
cacheRouterArray.push(this.$route.meta.componentName)
// cacheRouterArray.push("OnlCgformHeadList")
console.log("Vue ls set componentName :" + this.$route.meta.componentName)
Vue.ls.set(CACHE_INCLUDED_ROUTES, cacheRouterArray)
console.log("Vue ls includedRouterArrays :" + Vue.ls.get(CACHE_INCLUDED_ROUTES))
return cacheRouterArray;
}
}
return includedRouters;
},
//update-end--Author:scott Date:20201015 for:路由缓存问题,关闭了tab页时再打开就不刷新 #842
|
|
37
38
39
40
41
42
|
keepAlive () {
return this.$route.meta.keepAlive
}
},
}
</script>
|