feat: 命名

This commit is contained in:
wanchun 2022-03-22 12:27:17 +08:00
parent 3099bbd1b6
commit 0ee6ed2c83

View File

@ -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;
// namekeep-aliveinclude
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
};
}
};