mirror of
https://gitee.com/WeBank/fes.js.git
synced 2024-12-02 11:47:47 +08:00
feat: 命名
This commit is contained in:
parent
3099bbd1b6
commit
0ee6ed2c83
@ -37,7 +37,7 @@
|
||||
</router-view>
|
||||
</template>
|
||||
<router-view v-else v-slot="{ Component, route }">
|
||||
<keep-alive :include="includePages">
|
||||
<keep-alive :include="keepAlivePages">
|
||||
<component
|
||||
:is="getComponent(Component, route)"
|
||||
:key="getPageKey(route)"
|
||||
@ -151,7 +151,7 @@ export default {
|
||||
default:
|
||||
}
|
||||
};
|
||||
const includePages = ref([]);
|
||||
const keepAlivePages = ref([]);
|
||||
const getComponent = (Component, _route) => {
|
||||
if (_route.meta['keep-alive']) {
|
||||
const name = _route.meta?.name || _route.name;
|
||||
@ -159,8 +159,8 @@ export default {
|
||||
// 修改组件的 name
|
||||
Component.type.name = name;
|
||||
// 缓存的关键是组件name在keep-alive的include列表
|
||||
if (!includePages.value.includes(name)) {
|
||||
includePages.value = [...includePages.value, name];
|
||||
if (!keepAlivePages.value.includes(name)) {
|
||||
keepAlivePages.value = [...keepAlivePages.value, name];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,7 +177,7 @@ export default {
|
||||
handleCloseTab,
|
||||
actions,
|
||||
getComponent,
|
||||
includePages
|
||||
keepAlivePages
|
||||
};
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user